08.08.2012, 14:00
Quote:
Make a timer of 1 second,and then just define 2 variables name M and S(minutes and second).Define them in your gamemode like M=9,S=59;.Then change the timer to 1 second,and update the textdraw every seconds,the format is of course[pawn]0%d:%d[pawn].But you have to check when the variable S,when it's a single digit so the format woould change to
pawn Код:
Код:
09:10.....09:9 Код:
09:09 |
Here's how you do it:
pawn Код:
new time = TIME_IN_MILLI_SECONDS; // Fill in yourself (time in milliseconds)
SetTimer("CountDown", 1000, false); // Start timer somewhere
forward CountDown();
public CountDown() {
if(time > 0) {
new
szString[9],
minute, second
;
while(time > 1000 * 60) {
time -= (1000 * 60);
minute++;
}
second = (time/1000);
format(szString, sizeof(szString), "%02d:%02d", minute, second);
// Use szString somewhere (for example a GameText message)
// szString will hold the time (example: 03:55)
time -= 1000; // Decrease time by 1000 (1 second)
SetTime("CountDown", 1000, false); // Run again until time is 0
}
}