GetPedWeapon: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
(12 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function tells you which weapon type is in a certain weapon slot of a ped. | This function tells you which weapon type is in a certain '''[[weapon|weapon slot]]''' of a ped. | ||
==Syntax== | ==Syntax== | ||
Line 7: | Line 7: | ||
int getPedWeapon ( ped thePed, [ int weaponSlot = current ] ) | int getPedWeapon ( ped thePed, [ int weaponSlot = current ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[ped]]:getWeapon}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 12: | Line 13: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
*'''weaponSlot''': an integer representing the weapon slot (set to the ped's current slot if not given). | *'''weaponSlot''': an integer representing the [[weapon|weapon slot]] (set to the ped's current slot if not given). | ||
===Returns=== | ===Returns=== | ||
Returns an [[int]] indicating the type of the weapon the ped has in the specified slot. | Returns an [[int]] indicating the type of the weapon the ped has in the specified slot. If the slot is empty, it returns 0. | ||
It should be noted that if a ped runs out of ammo for a weapon, it will still return the ID of that weapon in the slot (even if it appears as if the ped does not have a weapon at all), though [[getPedTotalAmmo]] will return '''0'''. Therefore, [[getPedTotalAmmo]] should be used in conjunction with [[getPedWeapon]] in order to check if a ped has a weapon. | It should be noted that if a ped runs out of ammo for a weapon, it will still return the ID of that weapon in the slot (even if it appears as if the ped does not have a weapon at all), though [[getPedTotalAmmo]] will return '''0'''. Therefore, [[getPedTotalAmmo]] should be used in conjunction with [[getPedWeapon]] in order to check if a ped has a weapon. | ||
==Example== | ==Example== | ||
This | This example will display a player's current weapon type. In this case,a random player. | ||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Find a player called someguy and find his current weapon id. | -- Find a player called someguy and find his current weapon id. | ||
local weaponType = getPedWeapon ( | local weaponType = getPedWeapon ( getRandomPlayer() ) | ||
-- If a weapon type was returned then | -- If a weapon type was returned then | ||
if ( weaponType ) then | if ( weaponType ) then | ||
Line 29: | Line 31: | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Client_ped_functions}} | {{Client_ped_functions}} | ||
[[pt-br:GetPedWeapon]] |
Latest revision as of 02:00, 20 February 2022
This function tells you which weapon type is in a certain weapon slot of a ped.
Syntax
int getPedWeapon ( ped thePed, [ int weaponSlot = current ] )
OOP Syntax Help! I don't understand this!
- Method: ped:getWeapon(...)
Required Arguments
- thePed: the ped you want to get the weapon type from.
Optional Arguments
- weaponSlot: an integer representing the weapon slot (set to the ped's current slot if not given).
Returns
Returns an int indicating the type of the weapon the ped has in the specified slot. If the slot is empty, it returns 0.
It should be noted that if a ped runs out of ammo for a weapon, it will still return the ID of that weapon in the slot (even if it appears as if the ped does not have a weapon at all), though getPedTotalAmmo will return 0. Therefore, getPedTotalAmmo should be used in conjunction with getPedWeapon in order to check if a ped has a weapon.
Example
This example will display a player's current weapon type. In this case,a random player.
Click to collapse [-]
Server-- Find a player called someguy and find his current weapon id. local weaponType = getPedWeapon ( getRandomPlayer() ) -- If a weapon type was returned then if ( weaponType ) then outputChatBox ( "someguy's current Weapon-type: " .. weaponType .. "." ) -- Display the weapon type in the chat box end
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