SA-MP Forums Archive
Count down with textdraw - 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)
+--- Thread: Count down with textdraw (/showthread.php?tid=597286)



Count down with textdraw - zamaleksc - 29.12.2015

I created a player textdraw that count down and i use this snipped by Hiddos
Код:
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(counting[i], string);
}
but i get this error
Код:
 
error 001: expected token: "-string end-", but found "-identifier-"
warning 215: expression has no effect
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.



Re: Count down with textdraw - X337 - 29.12.2015

Код:
  if(seconds < 10) format(string, sizeof(string), "%d:%d", minutes, seconds);
  else format(string, sizeof(string), "%d:%d", minutes, seconds);



Re: Count down with textdraw - AndySedeyn - 29.12.2015

Use %02d instead of the unnecessary if statements.

Quote:
Originally Posted by X337
Посмотреть сообщение
Код:
  if(seconds < 10) format(string, sizeof(string), "%d:%d", minutes, seconds);
  else format(string, sizeof(string), "%d:%d", minutes, seconds);
Your code does the same thing in both cases.