{"hash":"0x4823F13A21F51964","ns":"WEAPON","name":"_GET_AMMO_IN_PED_WEAPON_FROM_GUID","slug":"_GET_AMMO_IN_PED_WEAPON_FROM_GUID","official":false,"named":true,"luaName":"GetAmmoInPedWeaponFromGuid","game":"rdr3","apiset":"client","returnType":"int","params":[{"name":"ped","type":"Ped"},{"name":"itemGuid","type":"Any*"}],"summary":"Returns the full amount of ammo the ped has for the weapon identified by itemGuid.","descriptions":[{"source":"alloc8or","format":"text","body":"Returns the full amount of ammo the ped has for the weapon identified by itemGuid.\nUse INVENTORY_GET_GUID_FROM_ITEMID to obtain the weapon GUID.\nExample: https://pastebin.com/u2Hcah3C"},{"source":"vorp","format":"text","body":"returns the full amount of ammo that the ped has for the weapon by guid"}],"examples":[{"lang":"lua","code":"local function inventoryGetGuidFromItemid(item, pGuid, slotId)\n    local outGuid = DataView.ArrayBuffer(8 * 13)\n    local result = Citizen.InvokeNative(0x886DFD3E185C8A89, 1, pGuid, item, slotId, outGuid:Buffer(), Citizen.ResultAsInteger());\n    if result ~= 1 then return nil end\n    return outGuid:Buffer();\nend\n\nRegisterCommand(\"getammo\", function()\n    local characterGuid = inventoryGetGuidFromItemid(`CHARACTER`, 0, `SLOTID_NONE`)\n    if not characterGuid then return end\n\n    local weaponGuid = inventoryGetGuidFromItemid(`CARRIED_WEAPONS`, characterGuid, `SLOTID_CARRIED_WEAPONS`)\n    if not weaponGuid then return end\n\n    local itemGuid = inventoryGetGuidFromItemid(`WEAPON_SNIPERRIFLE_CARCANO`, weaponGuid, `SLOTID_WEAPON_0`)\n    if not itemGuid then return end\n\n    local ammo = Citizen.InvokeNative(0x4823F13A21F51964, PlayerPedId(), itemGuid)\n    print(\"ammo: \" .. ammo)\nend, false)","source":"vorp"}],"aliases":["_GET_PED_WEAPON_AMMO_FROM_GUID"],"enums":[],"related":[],"build":"1207","sources":["alloc8or","vorp"],"doc":3,"url":"https://natives.borderlinerp.com/natives/WEAPON/_GET_AMMO_IN_PED_WEAPON_FROM_GUID","markdownUrl":"https://natives.borderlinerp.com/natives/WEAPON/_GET_AMMO_IN_PED_WEAPON_FROM_GUID.md","snippets":{"lua":"local retval, itemGuid = GetAmmoInPedWeaponFromGuid(ped, itemGuid)","luaInvoke":"local retval, itemGuid = Citizen.InvokeNative(0x4823F13A21F51964, ped, Citizen.PointerValueIntInitialized(itemGuid), Citizen.ResultAsInteger())","js":"const [retval, itemGuid] = GetAmmoInPedWeaponFromGuid(ped, itemGuid);","jsInvoke":"const [retval, itemGuid] = Citizen.invokeNative('0x4823F13A21F51964', ped, Citizen.pointerValueIntInitialized(itemGuid), Citizen.returnResultAnyway(), Citizen.resultAsInteger());","csharp":"var itemGuid = new OutputArgument();\nint retval = Function.Call<int>((Hash)0x4823F13A21F51964, ped, itemGuid);\n// itemGuid.GetResult<int>()","notes":["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."]}}