ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. setPedWeaponSlot

Function

setPedWeaponSlot

ServerPedsIdentical to MTA:SA

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