GetPedTarget
Jump to navigation
Jump to search
This function is used to get the element a ped is currently targeting.
Syntax
element getPedTarget ( ped thePed )
Required Arguments
- thePed: The ped whose target you want to retrieve.
Returns
Returns the element that's being targeted, or false if there isn't one.
This is only effective on physical GTA elements, namely:
- Players
- Vehicles
- Objects
Example
This example blows up any vehicle a player targets (aims at).
function playerTargetCheck ( ) local target for i, thePlayer in ipairs ( getElementsByType("player") ) do -- iterate over all players target = getPedTarget ( thePlayer ) -- get the target of the current player if ( target ) then -- if there was a target if ( getElementType ( target ) == "vehicle" ) then -- and the target is a vehicle blowVehicle ( target ) -- blow it up end end end end setTimer ( playerTargetCheck, 1000, 0 ) -- call the check function every second
Note: A more efficient way to do this would be to use the onPlayerTarget event.
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