M MY Multiplayer: Wiki
Side
Kind

getPedWeapon

Client

Gets the weapon a ped or player is holding, as this client knows it.

Also exists on the server, with its own implementation: getPedWeapon

int|false getPedWeapon(ped ped)

Parameters

NameTypeDescription
pedpedThe 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. A ped that is streamed out returns the last weapon this client knew it to hold.

Example

addCommandHandler("weapon", function()
    print(getPedWeapon(localPlayer))
end)
Coming from MTATakes no slot: it always returns the weapon in the current slot.

See also