GetPlayerTargetActor

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 20:37, 30 December 2016
OstGot (Talk | contribs)

← Previous diff
Current revision
OstGot (Talk | contribs)

Line 28: Line 28:
{{RelatedFunctions}} {{RelatedFunctions}}
 +{{GetPlayerTargetPlayer}}
{{GetPlayerCameraTargetActor}} {{GetPlayerCameraTargetActor}}
{{GetPlayerCameraFrontVector}} {{GetPlayerCameraFrontVector}}

Current revision



GetPlayerTargetActor was added in SA-MP 0.3.7 This function was added in SA-MP 0.3.7 and will not work in earlier versions!


Description:

Gets id of an actor which is aimed by certain player.


Parameters:
(playerid)
playeridThe ID of the player to get the target of.


Return Values:

The ID of the targeted actor, or INVALID_ACTOR_ID if none.


Image:32px-Circle-style-warning.png

Important
Notes

  • Does not work for joypads/controllers, and after a certain distance.
  • Does not work for the sniper rifle, as it doesn't lock on to anything and as such can't and won't return a player.


Example Usage:

public OnPlayerUpdate(playerid)
{
    new actorid = GetPlayerTargetActor(playerid);
 
    new string[32];
    format(string, sizeof(string), "You are aiming at actor id %d", actorid);
    SendClientMessage(playerid, -1, string);
    return 1;
}

Related Functions

The following functions may be helpful as they relate to this function in one way or another.


Related Callbacks

The following callbacks might be useful, as they're related to this function in one way or another.

Personal tools
In other languages