GetPlayerTargetActor

GetPlayerTargetActor

Description:
Function GetPlayerTargetActor gets id of an actor which is aimed by certain player.
Function GetPlayerTargetActor was added in 0.3.7 and will not work in earlier versions!
  • 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.


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


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


Examples:
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 useful, as they are related to this function in one way or another.


Related Callbacks
The following callbacks might be useful as well, as they are related to this callback in one way or another.