Lumaktaw patungo sa pangunahing content

GetPlayerTargetActor

warning

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.

NameDescription
playeridThe ID of the player to get the target of.

Returns

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

Examples

public OnPlayerUpdate(playerid)
{
new
targetActorId = GetPlayerTargetActor(playerid),
string[32];

format(string, sizeof(string), "You are aiming at actor id %d", targetActorId);
SendClientMessage(playerid, -1, string);
return 1;
}

Notes

warning

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.