- Documentation
- Server functions
- setPedWeaponSlot
Function
setPedWeaponSlot
Switches the weapon in a ped's hand to the one in the given inventory slot, as if the player scrolled the mouse wheel. The slot must contain a weapon; an empty slot (except 0, i.e. fists) gives false. The change reaches the player's game immediately.
Syntax
bool setPedWeaponSlot(ped ped, int slot)Arguments
pedped- A player or an NPC.
slotint- Slot 0-12 (0 = fists, 2 = handguns, 5 = assault rifles, etc.).
Returns
true on success, false when the slot is empty.
Example
addEventHandler("onPlayerSpawn", root, function()
giveWeapon(source, 24, 50)
setPedWeaponSlot(source, 0)
end)
See also
getPedWeaponSlotReturns the slot number (0-12) of the weapon a ped is currently holding. The slot follows from the weapon type: e.g. handguns are slot 2, assault rifles slot 5. When the ped is holding fists it returns 0.setCurrentWeaponPuts a weapon the ped already has into its hand (weapon number, e.g. 31 = M4; 0 = fists). Another name:setPedWeaponSlot.