SetPlayerAmmo

From SA-MP Wiki

Jump to: navigation, search


Description:

Set the ammo of a player's weapon.


Parameters:
(playerid, weaponid, ammo)
playeridThe ID of the player to set the weapon ammo of.
weaponidThe ID of the weapon to set the ammo of. (not the weaponslot as in samp include)
ammoThe amount of ammo to set.


Return Values:

  • 1: The function executed successfully. Success is also returned when the weapon slot specified is invalid (not 0-12).
  • 0: The function failed to execute. The player isn't connected.


Tip

Image:Light_bulb_icon.png

Set the ammo to 0 to remove a weapon from a player's inventory. Note that the weapon will still show up in GetPlayerWeaponData, albeit with 0 ammo.


Image:32px-Ambox_warning_orange.png

Note

The param 'weaponslot' is a typo in the sa-mp include. You must use the weapon ID and not the weapon slot of the weapon you would like to set the ammo of.


Example Usage:

SetPlayerAmmo(playerid, WEAPON_SHOTGUN, 100); // Set ammo of Shotgun to 100 bullets

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

  • GetPlayerAmmo: Check how much ammo a player has in the specified slot.
Personal tools
In other languages