SA-MP Forums Archive
Player aiming at oher player? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Player aiming at oher player? (/showthread.php?tid=586733)



Player aiming at oher player? - ax1 - 24.08.2015



I want to check if player is pressing some key when he's aiming at other player like that(photo). I've seen this in one server, but I don't know how to do it, is there callback or something?


Re: Player aiming at oher player? - Emmet_ - 24.08.2015

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new targetid = GetPlayerTargetPlayer(playerid);

    if (targetid != INVALID_PLAYER_ID)
    {
        // Perform a key check here.
    }
}



Re: Player aiming at oher player? - J0sh... - 24.08.2015

PHP код:
public OnPlayerUpdate(playerid) {
    new 
targetplayer GetPlayerTargetPlayer(playerid);
    if(
GetPlayerTeam(targetplayer) == GetPlayerTeam(playerid) && targetplayer != INVALID_PLAYER_ID)
    {
        
GameTextForPlayer(playerid"~R~do not shoot at team-mates!"50003);
    }

Source: https://sampwiki.blast.hk/wiki/GetPlayerTargetPlayer

Second Source for actors: https://sampwiki.blast.hk/wiki/GetPlayerTargetActor