SA-MP Forums Archive
Detect if player aiming. - 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: Detect if player aiming. (/showthread.php?tid=547324)



Detect if player aiming. - Banditukas - 22.11.2014

Hi,

How to right check if player aiming? now i'am doing onplayerkeystatechange

Код:
if( PRESSED( KEY_AIM ) )
	{

}
if( RELEASED( KEY_AIM ) )
	{

}
But it'is possible that player press key aim key right mouse button and can cancel a aiming without realising again mouse button?


Re: Detect if player aiming. - MasonSFW - 22.11.2014

pawn Код:
stock IsPlayerAiming(playerid)
{
    new anim = GetPlayerAnimationIndex(playerid);
    if (((anim >= 1160) && (anim <= 1163)) || (anim == 1167) || (anim == 1365) ||
    (anim == 1643) || (anim == 1453) || (anim == 220)) return 1;
    return 0;
}

public OnPlayerUpdate(playerid) // You can put under OnPlayerTakeDamage or others to detect players is aiming
{
        if(IsPlayerAiming(playerid))
        {
                //Your some thing do here
        }
        return 1;
}