# WEAPON::_GET_AMMO_IN_PED_WEAPON_FROM_GUID

- **Hash:** `0x4823F13A21F51964`
- **Namespace:** WEAPON
- **Runtime name (Lua/JS):** `GetAmmoInPedWeaponFromGuid`
- **Side:** client (game native)
- **Name status:** community guess (may change)
- **Documentation:** described with examples
- **Since game build:** 1207
- **Other names:** `_GET_PED_WEAPON_AMMO_FROM_GUID`
- **URL:** https://natives.borderlinerp.com/natives/WEAPON/_GET_AMMO_IN_PED_WEAPON_FROM_GUID

## Signature

```c
int _GET_AMMO_IN_PED_WEAPON_FROM_GUID(Ped ped, Any* itemGuid);
```

## Parameters

- `ped` (`Ped`)
- `itemGuid` (`Any*`)

## Returns

`int`

## Description

*Source: alloc8or RDR3 NativeDB*

Returns the full amount of ammo the ped has for the weapon identified by itemGuid.
Use INVENTORY_GET_GUID_FROM_ITEMID to obtain the weapon GUID.
Example: https://pastebin.com/u2Hcah3C

*Source: VORPCORE RDR3natives*

returns the full amount of ammo that the ped has for the weapon by guid

## Usage

### Lua

```lua
local retval, itemGuid = GetAmmoInPedWeaponFromGuid(ped, itemGuid)

-- always available, by hash
local retval, itemGuid = Citizen.InvokeNative(0x4823F13A21F51964, ped, Citizen.PointerValueIntInitialized(itemGuid), Citizen.ResultAsInteger())
```

### JavaScript

```js
const [retval, itemGuid] = GetAmmoInPedWeaponFromGuid(ped, itemGuid);

// by hash
const [retval, itemGuid] = Citizen.invokeNative('0x4823F13A21F51964', ped, Citizen.pointerValueIntInitialized(itemGuid), Citizen.returnResultAnyway(), Citizen.resultAsInteger());
```

### C#

```csharp
var itemGuid = new OutputArgument();
int retval = Function.Call<int>((Hash)0x4823F13A21F51964, ped, itemGuid);
// itemGuid.GetResult<int>()
```

- The last argument is an in/out pointer: pass its initial value, and the updated value is returned after the result.
- `Any*` arguments are often structs. Build them with a DataView buffer and pass it with `:Buffer()` — see the examples and notes below.
- The name is a community guess and may change. If the named call is missing in your client build, use `InvokeNative` with the hash — it always works.

## Examples

*Source: VORPCORE RDR3natives*

```lua
local function inventoryGetGuidFromItemid(item, pGuid, slotId)
    local outGuid = DataView.ArrayBuffer(8 * 13)
    local result = Citizen.InvokeNative(0x886DFD3E185C8A89, 1, pGuid, item, slotId, outGuid:Buffer(), Citizen.ResultAsInteger());
    if result ~= 1 then return nil end
    return outGuid:Buffer();
end

RegisterCommand("getammo", function()
    local characterGuid = inventoryGetGuidFromItemid(`CHARACTER`, 0, `SLOTID_NONE`)
    if not characterGuid then return end

    local weaponGuid = inventoryGetGuidFromItemid(`CARRIED_WEAPONS`, characterGuid, `SLOTID_CARRIED_WEAPONS`)
    if not weaponGuid then return end

    local itemGuid = inventoryGetGuidFromItemid(`WEAPON_SNIPERRIFLE_CARCANO`, weaponGuid, `SLOTID_WEAPON_0`)
    if not itemGuid then return end

    local ammo = Citizen.InvokeNative(0x4823F13A21F51964, PlayerPedId(), itemGuid)
    print("ammo: " .. ammo)
end, false)
```

*Sources: alloc8or RDR3 NativeDB, VORPCORE RDR3natives.*
