getPedWeapon
Server
Gets the weapon a ped or player is holding.
Also exists on the client, with its own implementation: getPedWeapon
int|false getPedWeapon(ped ped)
Parameters
| Name | Type | Description |
|---|---|---|
| ped | ped | The ped or player. |
Returns
The weapon type in the current slot (0 when the slot is empty), or false if the element is not a ped or a player.
The type is the weapon's type in the pack's weapon metadata, such as 22 for PISTOL.
Example
addCommandHandler("weapon", function(player)
outputDebugString(getPlayerName(player) .. " holds weapon " .. getPedWeapon(player))
end)Coming from MTATakes no slot: it always returns the weapon in the current slot.