GetPedAmmoInClip: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Client function}} This function returns an integer that contains the ammo in a specified ped's weapon. See Weapon Info ==Syntax== <syntaxhighlight lang="lua"> int getPedAmmoIn...) |
Zangomangu (talk | contribs) (Updated issues) |
||
(8 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Server client function}} | ||
This function returns an integer that contains the ammo in a specified [[ped]]'s weapon. See [[weapon|Weapon Info]] | This function returns an integer that contains the ammo in a specified [[ped]]'s weapon. See [[weapon|Weapon Info]] | ||
Line 7: | Line 7: | ||
int getPedAmmoInClip ( ped thePed [, int weaponSlot = current ] ) | int getPedAmmoInClip ( ped thePed [, int weaponSlot = current ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[ped]]:getAmmoInClip|ammoInClip}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 20: | Line 22: | ||
This example outputs the amount of ammo the specified player has in his current slot. For example: 'ammo someguy'. | This example outputs the amount of ammo the specified player has in his current slot. For example: 'ammo someguy'. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function showAmmo( command, who ) | function showAmmo(thePlayer, command, who ) | ||
local targetPlayer = | local targetPlayer = getPlayerFromName ( who ) | ||
if ( thePlayer ) then | if ( thePlayer ) then | ||
local ammo = getPedAmmoInClip ( targetPlayer ) | local ammo = getPedAmmoInClip ( targetPlayer ) | ||
Line 31: | Line 33: | ||
addCommandHandler( "ammo", showAmmo ) | addCommandHandler( "ammo", showAmmo ) | ||
</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}} | ||
[[hu:getPedAmmoInClip]] |
Latest revision as of 10:16, 30 January 2022
This function returns an integer that contains the ammo in a specified ped's weapon. See Weapon Info
Syntax
int getPedAmmoInClip ( ped thePed [, int weaponSlot = current ] )
OOP Syntax Help! I don't understand this!
- Method: ped:getAmmoInClip(...)
- Variable: .ammoInClip
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 currently selected slot if not specified).
Returns
Returns an int containing the amount of ammo in the specified ped's currently selected or specified clip, or 0 if the ped specified is invalid.
Example
This example outputs the amount of ammo the specified player has in his current slot. For example: 'ammo someguy'.
function showAmmo(thePlayer, command, who ) local targetPlayer = getPlayerFromName ( who ) if ( thePlayer ) then local ammo = getPedAmmoInClip ( targetPlayer ) outputChatBox ( who .. " has " .. ammo .. " ammo in his active clip" ) else outputChatBox ( "Player '" .. who .. "' not found." ) end end addCommandHandler( "ammo", showAmmo )
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