giveWeapon
Server
Gives a weapon with ammo to a ped or player.
bool giveWeapon(ped ped, string weapon [, int ammo = 30, bool setAsCurrent = false])
Parameters
| Name | Type | Description |
|---|---|---|
| ped | ped | The ped or player. |
| weapon | string | The weapon's name in the pack's weapon metadata, such as PISTOL or AK47. Case does not matter. |
| ammo | int | Ammo to give.default 30 |
| setAsCurrent | bool | true to switch to the weapon at once.default false |
Returns
true if the weapon was given. false if the weapon name is unknown, the ammo is negative or the element is not a ped or a player.
If the ped already has the same weapon in its slot, the ammo is added. A different weapon in the same slot is replaced. A slot's ammo is capped at 99999.
Example
addEventHandler("onPlayerSpawn", root, function()
giveWeapon(source, "PISTOL", 60, true)
giveWeapon(source, "KNIFE", 1)
end)Coming from MTATakes the weapon's name instead of its id.