Checking for timer at 0
#4

When the timer is over, it's basically 0.. Unless you want to create another variable to track the timer's seconds which is useless.

So, you will need something like this:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_JUMP)
    {
        PlayerPressedJump[playerid] ++;
        if(PlayerPressedJump[playerid] == 3) // change 5 to whatever number of jumps you want
        {
            ApplyAnimation(playerid, "PED", "BIKE_fall_off", 4.1, 0, 1, 1, 1, 0, 1);
            SetTimerEx("PressJump", 15000, false, "i", playerid); // When the timer reaches 0, we move to the callback "PressJump"
        }
    }
    return 1;
}

forward PressJump(playerid); // Timer is over.
public PressJump(playerid)
{
    PlayerPressedJump[playerid] = 0; // Reset the variable
    ClearAnimations(playerid);
    return 1;
}
So basically, the "if" check is not necessary in this case.
Reply


Messages In This Thread
Checking for timer at 0 - by Joshb93 - 20.11.2011, 05:36
Re: Checking for timer at 0 - by antonio112 - 20.11.2011, 05:41
Re: Checking for timer at 0 - by Joshb93 - 20.11.2011, 05:47
Re: Checking for timer at 0 - by [L3th4l] - 20.11.2011, 05:52
Re: Checking for timer at 0 - by cessil - 20.11.2011, 05:53
Re: Checking for timer at 0 - by antonio112 - 20.11.2011, 06:05

Forum Jump:


Users browsing this thread: 1 Guest(s)