GetPlayerTarget: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
This function is used to get the current entity a [[player]] is targeting.
This function is used to get the current element a [[player]] is targeting.


==Syntax==
==Syntax==
Line 12: Line 12:
===Returns===
===Returns===
Returns the [[element]] that's being targeted, or ''false'' if there isn't one.
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==
==Example==

Revision as of 09:01, 22 August 2006

This function is used to get the current element a player is targeting.

Syntax

element getPlayerTarget ( player thePlayer )

Required Arguments

  • thePlayer: The player 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 specified player targets (aims at)

function playerTargetCheck ( thePlayer ) -- called on a timer
  target = getPlayerTarget ( thePlayer ) -- get the current target of the player
  if ( target ) then -- if there was a target
    if ( getElementType ( target ) == "vehicle" ) then -- if the target is a vehicle
      blowVehicle ( target ) -- blow the vehicle
    end
  end
end

See Also