GetPedTotalAmmo: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Client function}} This function returns an integer that contains the total ammo in a specified ped's weapon. See Weapon Info ==Syntax== <syntaxhighlight lang="lua"> int getPed...) |
m (Update issues) |
||
(13 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Server client function}} | ||
This function returns an integer that contains the total ammo in a specified [[ped]]'s weapon. See [[weapon|Weapon Info]] | This function returns an integer that contains the total ammo in a specified [[ped]]'s weapon. See [[weapon|Weapon Info]] | ||
{{Note|Clientside, this function will not return a correct value for remote player weapons that aren't in hand.}} | |||
==Syntax== | ==Syntax== | ||
Line 7: | Line 8: | ||
int getPedTotalAmmo ( ped thePed, [ int weaponSlot = current ] ) | int getPedTotalAmmo ( ped thePed, [ int weaponSlot = current ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[ped]]:getTotalAmmo}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 21: | Line 23: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Find the player called 'Someguy' | -- Find the player called 'Someguy' | ||
myPlayer = | myPlayer = getPlayerFromName ( "Someguy" ) | ||
-- If a player called 'Someguy' was found then | -- If a player called 'Someguy' was found then | ||
if ( myPlayer ) then | if ( myPlayer ) then | ||
Line 30: | Line 32: | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Issues== | |||
{{Issues| | |||
{{Issue|734|Sometimes wrong count of player ammo, if get it in onPlayerWeaponFire}} | |||
}} | |||
==See Also== | ==See Also== | ||
{{Client_ped_functions}} | {{Client_ped_functions}} |
Latest revision as of 13:45, 24 September 2024
This function returns an integer that contains the total ammo in a specified ped's weapon. See Weapon Info
Syntax
int getPedTotalAmmo ( ped thePed, [ int weaponSlot = current ] )
OOP Syntax Help! I don't understand this!
- Method: ped:getTotalAmmo(...)
Required Arguments
- thePed: The ped whose ammo you want to check.
Optional Arguments
- weaponSlot: an integer representing the weapon slot (set to the ped's current slot if not given)
Returns
Returns an int containing the total amount of ammo for the specified ped's weapon, or 0 if the ped specified is invalid.
Example
This example outputs the total amount of ammo a player called Someguy has for his weapon.
-- Find the player called 'Someguy' myPlayer = getPlayerFromName ( "Someguy" ) -- If a player called 'Someguy' was found then if ( 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 .. "." ) end
Issues
Issue ID | Description |
---|---|
#734 | Sometimes wrong count of player ammo, if get it in onPlayerWeaponFire |
See Also
- canPedBeKnockedOffBike
- getPedAnalogControlState
- getPedAnimation
- getPedBonePosition
- getPedCameraRotation
- getPedControlState
- getPedMoveState
- getPedOxygenLevel
- getPedSimplestTask
- getPedTargetCollision
- getPedTargetEnd
- getPedTargetStart
- getPedTask
- getPedVoice
- getPedWeaponMuzzlePosition
- givePedWeapon
- isPedBleeding
- isPedDoingTask
- isPedReloadingWeapon
- isPedTargetingMarkerEnabled
- setAnalogControlState
- setPedAimTarget
- setPedAnalogControlState
- setPedBleeding
- setPedCameraRotation
- setPedCanBeKnockedOffBike
- setPedControlState
- setPedEnterVehicle
- setPedExitVehicle
- IsPedFootBloodEnabled
- setPedFootBloodEnabled
- setPedLookAt
- setPedOxygenLevel
- setPedTargetingMarkerEnabled
- setPedVoice
- Shared
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle