- Documentation
- Server functions
- giveWeapon
Function
giveWeapon
Gives a ped a weapon with ammo. If the ped already has a weapon in that slot, it is replaced.
Syntax
bool giveWeapon(ped ped, int weapon [, int ammo = 0, bool setAsCurrent = true])Arguments
pedped- A player or ped.
weaponint- Weapon ID.
ammoint, optional = 0- Amount of ammo.
setAsCurrentbool, optional = true- Whether to put the weapon in hand right away.Different default in MTA:SA: bool setAsCurrent = false
Differences from MTA:SA
- Arguments in a different colour differ from MTA:SA.
In MTA:SA
giveWeapon(ped thePlayer, int weapon, int ammo = 30, bool setAsCurrent = false)Returns
true if the weapon was given.
Example
addEventHandler("onPlayerSpawn", root, function()
giveWeapon(source, 24, 50)
giveWeapon(source, 31, 300, true)
end)