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

Function

givePedWeapon

ServerPedsIdentical to MTA:SA

Gives a ped a weapon with ammo, exactly like giveWeapon (it is the same function under another name). If the ped already has a weapon in the same slot, it is replaced, while ammo for the same weapon adds up.

Syntax

bool givePedWeapon(ped ped, int weapon [, int ammo = 30, bool setAsCurrent = false])

Arguments

pedped
A player or an NPC.
weaponint
Weapon ID, e.g. 24 = Desert Eagle, 31 = M4, 34 = sniper rifle.
ammoint, optional = 30
Number of rounds to add.
setAsCurrentbool, optional = false
true = the ped takes the weapon in hand right away.

Returns

true on success.

Example

addCommandHandler("m4", function(player)
    givePedWeapon(player, 31, 200, true)
end)

See also