Pressing a key, an amount of times.
#2

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Set a timer for 20 seconds, create a new variable like so...

pawn Код:
new TimesPressed [ MAX_PLAYERS ] = 0, TimerActive [ MAX_PLAYERS ] = 0;
SetTimerEx ( "PressedNumberofTimes", 20000, false, "i", playerid );
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( PRESSED ( KEY_SPRINT ) )
    {
        if( TimerActive [ playerid ] == 1 )
        {
            TimesPressed [ playerid ] ++;
        }
    }
    return true;
}

forward PressedNumberofTimes ( playerid );
public PressedNumberofTimes ( playerid )
{
    if( TimesPressed [ playerid ] >= 20 )
    {
        // Success!
        TimesPressed [ playerid ] = 0;
    }
    else
    {
        // Failure!
    }
    return true;
}
Reply


Messages In This Thread
Pressing a key, an amount of times. - by JamesS - 15.02.2013, 00:21
Re: Pressing a key, an amount of times. - by 2KY - 15.02.2013, 00:27
Re: Pressing a key, an amount of times. - by JamesS - 15.02.2013, 10:49
Re: Pressing a key, an amount of times. - by 2KY - 15.02.2013, 10:53
Re: Pressing a key, an amount of times. - by MP2 - 15.02.2013, 11:15
Re: Pressing a key, an amount of times. - by 2KY - 15.02.2013, 15:16
Re: Pressing a key, an amount of times. - by Scenario - 15.02.2013, 15:21
Re: Pressing a key, an amount of times. - by 2KY - 15.02.2013, 15:25
Re: Pressing a key, an amount of times. - by Scenario - 15.02.2013, 15:26
Re: Pressing a key, an amount of times. - by 2KY - 15.02.2013, 15:28

Forum Jump:


Users browsing this thread: 3 Guest(s)