How to do these Key Checks?
#4

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;
}
Reply


Messages In This Thread
How to do these Key Checks? - by Bcklup - 08.07.2010, 02:00
Re: How to do these Key Checks? - by mprofitt - 08.07.2010, 02:16
Re: How to do these Key Checks? - by Bcklup - 09.07.2010, 01:45
Re: How to do these Key Checks? - by bigcomfycouch - 09.07.2010, 03:41
Re: How to do these Key Checks? - by Bcklup - 09.07.2010, 06:59

Forum Jump:


Users browsing this thread: 1 Guest(s)