WeaponClient1 output

getMaxAmmoByType

GET_MAX_AMMO_BY_TYPE0x585847C5E4E11709

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

SignatureJavaScript
getMaxAmmoByType(ped: Ped, ammoTypeHash: Hash): [ok: boolean, ammo: number]
SignatureLua
getMaxAmmoByType(ped: Ped, ammoTypeHash: Hash): boolean, integer

Usage

JavaScript
const [ok, ammo] = getMaxAmmoByType(ped, ammoTypeHash);
Lua
local ok, ammo = getMaxAmmoByType(ped, ammoTypeHash)

Parameters

ParameterTypeJavaScriptLua
pedPednumberinteger
ammoTypeHashHashnumberinteger

Returns

2 values, in this order: an array in JavaScript, multiple return values in Lua.

#ValueTypeJavaScriptLuaDescription
1okBOOLbooleanbooleanThe native’s own return value.
2ammointnumberintegeroutput

Notes

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

Returns the max ammo for an ammo type. Ammo types: https://gist.github.com/root-cause/faf41f59f7a6d818b7db0b839bd147c1

Reference

Namespace
Weapon WEAPON
In the game
BOOL GET_MAX_AMMO_BY_TYPE(Ped ped, Hash ammoTypeHash, int* ammo)
Hash
0x585847C5E4E11709
Introduced
Game build 1103 legacy numbering
Formerly
_GET_MAX_AMMO_2 _GET_MAX_AMMO_BY_TYPE

Open in the interactive natives reference