- Documentation
- Shared functions
- getPedTotalAmmo
Function
getPedTotalAmmo
Returns all ammo for a weapon (clip plus reserve). Without a slot it refers to the weapon in hand; with a slot, to the weapon in that inventory slot. On the client it always refers to the weapon in hand.
Syntax
int getPedTotalAmmo(ped ped [, int slot = nil])Arguments
pedped- A player or an NPC.
slotint, optional = nil- Slot 0-12. Omitted = the weapon in hand. Ignored on the client.
Returns
Total number of rounds.
Example
addCommandHandler("amunicja", function(player)
outputChatBox("Naboje: " .. getPedTotalAmmo(player), player)
end)
See also
getPedAmmoInClipReturns the number of rounds in the weapon's current clip, i.e. how many shots are left before reloading. Without a slot it refers to the weapon in hand; with a slot, to the weapon in that inventory slot. On the client it always refers to the weapon in hand.getPedWeaponReturns the ID of the weapon a ped is holding (0 = fists), or of the weapon in the given inventory slot. Slots are weapon groups: 0 fists, 1 melee, 2 handguns, 3 shotguns, 4 sub-machine guns, 5 assault rifles, 6 rifles, 7 heavy weapons, 8 grenades, 9 sprays and extinguishers, 10 gifts, 11 goggles and parachute, 12 detonator. On the client it returns only the weapon in hand.setWeaponAmmoSets ammo. For a ped it sets the ammo of a given weapon; for a scripted weapon it sets its reserve.