getPedTarget | Multi Theft Auto: Wiki Skip to content

getPedTarget

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function is used to get the element a ped is currently targeting.

Syntax

getPedTarget ( )

Code Examples

server

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

See Also