GetPlayerAmmo
From SA-MP Wiki
GetPlayerAmmo
Returns the amount of ammunition the player has in his active weapon slot.
(playerid)
| playerid | ID of the player |
| Returns | The amount of ammunition the player has in his active weapon slot. |
new ammo = GetPlayerAmmo(playerid);
To get player's ammo (while GetPlayerAmmo is broken), you can use this:
stock GetAmmo(playerid) { new d[2], slot = -1; switch(GetPlayerWeapon(playerid)) { case 0, 1: slot = 0; case 2..9: slot = 1; case 22..24: slot = 2; case 25..27: slot = 3; case 28, 29, 32: slot = 4; case 30, 31: slot = 5; case 33, 34: slot = 6; case 35..38: slot = 7; case 16..19, 39: slot = 8; case 41..43: slot = 9; case 10..15: slot = 10; case 44..46: slot = 11; case 40: slot = 12; } if(slot == -1) return -1; GetPlayerWeaponData(playerid,slot,d[0],d[1]); return d[1]; }
Related Functions
The following functions might be useful as well, as they're related to this function in one way or another.
- SetPlayerAmmo: Set the ammo of a specific player's weapon.
- GetPlayerWeaponData: Find out information about weapons a player has.
