timer with textdraw LOOK! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: timer with textdraw LOOK! (
/showthread.php?tid=174752)
timer with textdraw LOOK! -
thomas.. - 06.09.2010
how to update the textdraw with a timer?
such as
endround
5:00
and it counts down..
sorry to be making a topic right after my last one just i wanna find out stuff!
and dont post crap about searching.. already tried
Re: timer with textdraw LOOK! -
Relixious - 06.09.2010
- Make 2 variables for the minutes and seconds.
- Set a timer that calls every second.
- Put in the public, that everytime it will do a second --; if the seconds is 0 or lower put seconds back to 59 and do minutes --;
Re: timer with textdraw LOOK! -
Hiddos - 06.09.2010
pawn Код:
forward CountDown(seconds);
public CountDown(seconds)
{
if(seconds == 0)
{
//All your code for when the timer reaches 0
return; //THIS IS ESSENTIAL TO WORK!!!
}
SetTimerEx("CountDown", 1000, 0, "d", seconds-1);
new minutes;
while(seconds < 59)
{
seconds -= 60;
minutes++;
}
new string[8];
if(seconds < 10) format(string, sizeof string, "%d:0%d" minutes, seconds);
else format(string, sizeof string, "%d:%d" minutes, seconds);
TextDrawSetString(<YOUR TEXTDRAW ID>, string);
}
To start a countdown:
You could also do "seconds*minutes", if you want for example 8 minutes you can type:
pawn Код:
CountDown(8*60); //8 times 60 is 8 minutes
Re: timer with textdraw LOOK! -
thomas.. - 06.09.2010
Quote:
Originally Posted by Hiddos
pawn Код:
forward CountDown(seconds); public CountDown(seconds) { if(seconds == 0) { //All your code for when the timer reaches 0 return; //THIS IS ESSENTIAL TO WORK!!! } SetTimerEx("CountDown", 1000, 0, "d", seconds); new minutes; while(seconds < 59) { seconds -= 60; minutes++; } new string[8]; if(seconds < 10) format(string, sizeof string, "%d:0%d" minutes, seconds); else format(string, sizeof string, "%d:%d" minutes, seconds); TextDrawSetString(<YOUR TEXTDRAW ID>, string); }
To start a countdown:
You could also do "seconds*minutes", if you want for example 8 minutes you can type:
pawn Код:
CountDown(8*60); //8 times 60 is 8 minutes
|
thank you Hiddos!