getPedTotalAmmo
Client-side
Server-side
Shared
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function returns an integer that contains the total ammo in a specified ped's weapon. See Weapon Info
Note
Clientside, this function will not return a correct value for remote player weapons that aren't in hand.
OOP Syntax Help! I don't understand this!
- Method:ped:getTotalAmmo(...)
Syntax
int getPedTotalAmmo ( ped thePed, [ int weaponSlot = current ] )Required Arguments
- thePed: The ped whose ammo you want to check.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- weaponSlot (default: current): an integer representing the weapon slot (set to the ped's current slot if not given)
Returns
- int: value
Returns an int containing the total amount of ammo for the specified ped's weapon, or 0 if the ped specified is invalid.
Code Examples
shared
This example outputs the total amount of ammo a player calledSomeguyhas for his weapon.
-- Find the player called 'Someguy'myPlayer = getPlayerFromName ( "Someguy" )-- If a player called 'Someguy' was found thenif ( myPlayer ) then -- Retrieve the total amount of ammo for that player, and store it in a variable called 'ammo' ammo = getPedTotalAmmo ( myPlayer ) -- Tell all the players how much ammo 'Someguy' has outputChatBox ( "Someguy's current total ammo: " .. ammo .. "." )endIssues
| ID | Description |
|---|---|
| 734 | Sometimes wrong count of player ammo, if get it in onPlayerWeaponFire |
See Also
Ped Functions
- addPedClothes
- canPedBeKnockedOffBike
- createPed
- getPedAmmoInClip
- getPedAnalogControlState
- getPedAnimation
- getPedArmor
- getPedBonePosition
- getPedCameraRotation
- getPedClothes
- getPedContactElement
- getPedControlState
- getPedFightingStyle
- getPedGravity
- getPedMoveState
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedOxygenLevel
- getPedSimplestTask
- getPedStat
- getPedTarget
- getPedTargetCollision
- getPedTargetEnd
- getPedTargetStart
- getPedTask
- getPedTotalAmmo
- getPedVoice
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponMuzzlePosition
- getPedWeaponSlot
- getValidPedModels
- givePedWeapon
- isPedBleeding
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDoingTask
- isPedDucked
- IsPedFootBloodEnabled
- isPedHeadless
- isPedInVehicle
- isPedOnGround
- isPedReloadingWeapon
- isPedTargetingMarkerEnabled
- isPedWearingJetpack
- killPed
- playPedVoiceLine
- reloadPedWeapon
- removePedClothes
- removePedFromVehicle
- resetPedVoice
- setPedAimTarget
- setPedAnalogControlState
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedBleeding
- setPedCameraRotation
- setPedCanBeKnockedOffBike
- setPedChoking
- setPedControlState
- setPedDoingGangDriveby
- setPedEnterVehicle
- setPedExitVehicle
- setPedFightingStyle
- setPedFootBloodEnabled
- setPedGravity
- setPedHeadless
- setPedLookAt
- setPedOxygenLevel
- setPedStat
- setPedTargetingMarkerEnabled
- setPedVoice
- setPedWalkingStyle
- setPedWeaponSlot
- setPedWearingJetpack
- warpPedIntoVehicle