Countdown
#6

Quote:
Originally Posted by BigETI
Посмотреть сообщение
pawn Код:
#define MAX_TIME    180 //Add here your time in seconds. 180 seconds/60 seconds per minute makes 3 minutes

new Text:TimeText, ticked, countdowntimer;

forward Tick();

public Tick()
{
    ticked++;
    new ticktime = MAX_TIME-ticked, tempticktime = ticktime, minutes = 0;
    while(tempticktime > 59)
    {
        minutes++;
        tempticktime = tempticktime-60;
    }
    format(str, sizeof(str), "%02d:%02d", minutes, tempticktime);
    TextDrawSetString(TimeText, str);
    if(ticktime == 0)
    {
        KillTimer(countdowntimer);
        //Do here your things when the time end.
    }
}

public OnGameModeInit()
{
    TimeText = TextDrawCreate(550.0, 33.0, "--:--");
    new ticktime = MAX_TIME, minutes = 0;
    while(ticktime > 59)
    {
        minutes++;
        ticktime = ticktime-60;
    }
    new str[128];
    format(str, sizeof(str), "%02d:%02d", minutes, ticktime);
    TextDrawSetString(TimeText, str);
    countdowntimer = SetTimer("Tick", 1000, true);
    return 1;
}

public OnPlayerConnect(playerid)
{
    TextDrawShowForPlayer(playerid, TimeText);
    return 1;
}
Fucking awesome dude, you got credits :)
Reply


Messages In This Thread
Countdown - by Markx - 27.05.2011, 19:59
Re: Countdown - by Seven_of_Nine - 27.05.2011, 20:19
Re: Countdown - by Markx - 27.05.2011, 20:47
Re: Countdown - by Seven_of_Nine - 27.05.2011, 21:07
Re: Countdown - by BigETI - 27.05.2011, 21:27
Re: Countdown - by Markx - 28.05.2011, 08:44
Re: Countdown - by cs_master - 28.05.2011, 09:05
Re: Countdown - by BigETI - 28.05.2011, 10:28

Forum Jump:


Users browsing this thread: 4 Guest(s)