RedM Natives

_GET_AMMO_IN_PED_WEAPON_FROM_GUID

Returns the full amount of ammo the ped has for the weapon identified by itemGuid.

Hash0x4823F13A21F51964
Runtime nameGetAmmoInPedWeaponFromGuid
NamespaceWEAPON
SideClient
NameCommunity guess
Docs
Since build1207
Also known as_GET_PED_WEAPON_AMMO_FROM_GUID

Signature

int _GET_AMMO_IN_PED_WEAPON_FROM_GUID(Ped ped, Any* itemGuid);

Parameters

NameTypeDescription
pedPed—
itemGuidAny*—

Returns int

Description

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

VORPCORE RDR3natives

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

Usage

Lua
local retval, itemGuid = GetAmmoInPedWeaponFromGuid(ped, itemGuid)

-- always works, by hash
local retval, itemGuid = Citizen.InvokeNative(0x4823F13A21F51964, ped, Citizen.PointerValueIntInitialized(itemGuid), Citizen.ResultAsInteger())
JavaScript and C#
JavaScript
const [retval, itemGuid] = GetAmmoInPedWeaponFromGuid(ped, itemGuid);

// by hash
const [retval, itemGuid] = Citizen.invokeNative('0x4823F13A21F51964', ped, Citizen.pointerValueIntInitialized(itemGuid), Citizen.returnResultAnyway(), Citizen.resultAsInteger());
C#
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

LUA · VORPCORE RDR3natives
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

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.