SA-MP Forums Archive
How to do these Key Checks? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to do these Key Checks? (/showthread.php?tid=157875)



How to do these Key Checks? - Bcklup - 08.07.2010

I was planning on a Rushing System, i wanted it to check if u "Double Tapped W","Double Tapped W + Sprint". and other related keys, i think its possible but i don't know how because I'm not really used to key based things


Re: How to do these Key Checks? - mprofitt - 08.07.2010

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange

This should open up a whole new world for you then.


Re: How to do these Key Checks? - Bcklup - 09.07.2010

I know how to do some of those but i want a bit more of a Specific Answer


Re: How to do these Key Checks? - bigcomfycouch - 09.07.2010

wrote this quickly

pawn Код:
#define KEY_W -128

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_W)
    {
        if(GetPVarInt(playerid, "lastkey") != KEY_W) SetPVarInt(playerid, "lastkey", KEY_W);
        else
        {
            SetPVarInt(playerid, "pressedwtwice", 1);
            // they've hit w twice in a row
        }
        return 1;
    }
    if(newkeys & KEY_SPRINT)
    {
        if(GetPVarInt(playerid, "pressedwtwice") == 1)
        {
            // they have pressed w twice in a row and then sprint
            SetPVarInt(playerid, "pressedwtwice", 0);
        }
        return 1;
    }
    SetPVarInt(playerid, "lastkey", 65535);
    SetPVarInt(playerid, "pressedwtwice", 0);
    return 1;
}



Re: How to do these Key Checks? - Bcklup - 09.07.2010

I wanted a "Holding Sprint + Double Tap W" but ill do that myself
Haven't tested yet because i'm lazy but thanks