From SA-MP Wiki

Jump to: navigation, search

GetPlayerTargetPlayer was added in SA-MP 0.3d This function was added in SA-MP 0.3d and will not work in earlier versions!


Check who a player is aiming at.

playeridThe ID of the player to get the target of.

Return Values:

The ID of the target player, or INVALID_PLAYER_ID if none.



  • 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)
    // Store the ID
    new targetplayer = GetPlayerTargetPlayer(playerid);
    if(GetPlayerTeam(targetplayer) == GetPlayerTeam(playerid) && targetplayer != INVALID_PLAYER_ID)
        GameTextForPlayer(playerid, "~R~do not shoot at team-mates!", 5000, 3);

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