timer with textdraw LOOK!
#1

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
Reply
#2

- 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 --;
Reply
#3

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:
pawn Код:
CountDown(<seconds>);
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
Reply
#4

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:
pawn Код:
CountDown(<seconds>);
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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)