SA-MP Forums Archive
shooting disable bug - 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: shooting disable bug (/showthread.php?tid=444777)



shooting disable bug - ajwar - 18.06.2013

So i wan't to disable shooting in safe zone.

pawn Код:
public OnPlayerUpdate(playerid)
{
if(IsPlayerShoting(playerid) && IsPlayerInSafeZone(playerid)){SetPlayerArmedWeapon(playerid, 0);ClearAnimations(playerid);}
return 1;

}
pawn Код:
stock IsPlayerShoting(playerid)
{
        new anim = GetPlayerAnimationIndex(playerid);
        if (((anim >= 1160) && (anim <= 1163)) || (anim == 1167) || (anim == 1365) || (anim == 1643) || (anim == 1453) || (anim == 220) || (anim == 1333) || (anim == 1333) || (anim ==1167) || (anim ==1365) || (anim ==1643) || (anim ==1453) || (anim ==220)) return 1;
        return 0;
}
If i simply press shooting button shooting won't work, but if i hold shooting button with no gun and then change to any gun while holding it forks fine. How to disable shooting on that hold+change bug?


Re: shooting disable bug - DobbysGamertag - 18.06.2013

Use OnPlayerKeyStateChange.

Use
pawn Код:
if(PRESSED(KEY_NAME))
Then use
pawn Код:
if(HOLDING(KEY_NAME))
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange


Re: shooting disable bug - ajwar - 18.06.2013

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInSafeZone(playerid) && PRESSED(KEY_FIRE))
    {
        if(HOLDING(KEY_FIRE)) SetPlayerArmedWeapon(playerid, 0);
    }
}
I can still shoot . Any other suggestions?


Re: shooting disable bug - DobbysGamertag - 18.06.2013

Try it like this?

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(HOLDING(KEY_FIRE))
    {
        if(IsPlayerInSafeZone(playerid)
        {
            SetPlayerArmedWeapon(playerid, 0);
            ClearAnimations(playerid);
        }
    }
    if(PRESSED(KEY_FIRE))
    {
        if(IsPlayerInSafeZone(playerid)
        {
            SetPlayerArmedWeapon(playerid,0);
            ClearAnimations(playerid);
        }
    }
    return 1;
}



Re: shooting disable bug - ajwar - 18.06.2013

still no problem to shoot


Re: shooting disable bug - ajwar - 18.06.2013

any other suggestions?