WeaponClient

getPedAmmoTypeFromWeapon

GET_PED_AMMO_TYPE_FROM_WEAPON0x7FEAD38B326B9F74

The GTA V native GET_PED_AMMO_TYPE_FROM_WEAPON of the WEAPON namespace, as LS:MP client scripts call it: the global function getPedAmmoTypeFromWeapon, in JavaScript and in Lua.

SignatureJavaScript
getPedAmmoTypeFromWeapon(ped: Ped, weaponHash: Hash): Hash
SignatureLua
getPedAmmoTypeFromWeapon(ped: Ped, weaponHash: Hash): Hash

Usage

JavaScript
const hash = getPedAmmoTypeFromWeapon(ped, weaponHash);
Lua
local hash = getPedAmmoTypeFromWeapon(ped, weaponHash)

Parameters

ParameterTypeJavaScriptLua
pedPednumberinteger
weaponHashHashnumberinteger

Returns

Hash JavaScript number, Lua integer

A game hash. Natives return it unsigned (0 to 4294967295), the value lsmp.hash gives. As an argument, the signed and unsigned forms of a hash are the same value.

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

Returns the current ammo type of the specified ped's specified weapon.
MkII magazines will change the return value, like Pistol MkII returning AMMO_PISTOL without any components and returning AMMO_PISTOL_TRACER after Tracer Rounds component is attached.
Use getPedOriginalAmmoTypeFromWeapon if you always want AMMO_PISTOL.
Full list of weapons by DurtyFree: https://github.com/DurtyFree/gta-v-data-dumps/blob/master/weapons.json

Reference

Namespace
Weapon WEAPON
In the game
Hash GET_PED_AMMO_TYPE_FROM_WEAPON(Ped ped, Hash weaponHash)
Hash
0x7FEAD38B326B9F74
Formerly
_GET_PED_AMMO_TYPE

Open in the interactive natives reference