SA-MP Forums Archive
need little help in keystatechange. - 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: need little help in keystatechange. (/showthread.php?tid=463866)



need little help in keystatechange. - Champ - 14.09.2013

Hello, I got a little problem.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_ACTION))
    {
        // My enabled code
    }
    else if (PRESSED(KEY_ACTION))
    {
        // My disabled code
    }
    return 1;
}
when i press action key, it enables. But when i press that key again, it doesn't disable.


Re: need little help in keystatechange. - iJumbo - 14.09.2013

pawn Код:
new SomeVar[MAX_PLAYERS];
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_ACTION))
    {
        if(SomeVar[playerid] == 0) {
            // My enabled code
            SomeVar[playerid] = 1;
        } else {
            // My disabled code
            SomeVar[playerid] = 0;
        }
    }
    return 1;
}
YOu can do like that.. and will be (Tap (activated) Tap (deactivated)

or you can use RELEASED .. check samp wiki for RELEASED


Re: need little help in keystatechange. - Champ - 14.09.2013

Thank You BRO!
++Rep;