warning Not Translated
This page has not been translated into the language that your browser requested yet. The English content is being shown as a fallback.
If you want to contribute a translation for this page then please click here.
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.
Name | Description |
---|---|
playerid | The 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.
Related Functions
- GetPlayerCameraTargetActor: Get the ID of the actor (if any) a player is looking at.
- GetPlayerCameraFrontVector: Get the player's camera front vector
Related Callbacks
- OnPlayerGiveDamageActor: This callback is called when a player gives damage to an actor.