SA-MP Forums Archive
Countdown timer giving error :s - 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: Countdown timer giving error :s (/showthread.php?tid=147352)



Countdown timer giving error :s - ~Dangun! - 11.05.2010

It is giving this error:
Код:
syntax error in the expression, or invalid function call
pawn Код:
public Timer()
{
    gTimePassed++;
  new timeleft = ROUND_TIME * 60 - gTimePassed; //This is the error line :S

    new minutes = timeleft / 60;
    new seconds = timeleft - minutes * 60;
   
    new tmpmsg[128];
    format(tmpmsg,sizeof(tmpmsg),"%d:%d",minutes, seconds);
    TextDrawSetString(TimerCD, tmpmsg);
    TextDrawShowForAll(TimerCD);

}



Re: Countdown timer giving error :s - Killa_ - 11.05.2010

pawn Код:
new timeleft = (ROUND_TIME * 60) - gTimePassed;



Re: Countdown timer giving error :s - ~Dangun! - 11.05.2010

still having it (the error)


Re: Countdown timer giving error :s - Killa_ - 11.05.2010

Post the error and ROUND_TIME variable


Re: Countdown timer giving error :s - ~Dangun! - 11.05.2010

Also the error stays the same
pawn Код:
public ROUND_TIME()
{
    new string[265];
    format(string,sizeof(string),"Test round is over");
    SendClientMessageToAll(0x33CCFFAA,string);
}



Re: Countdown timer giving error :s - Jokerstyle - 12.05.2010

It seems like there is nothign wrong with it lol, probably someone knows how to fix it.


Re: Countdown timer giving error :s - maij - 12.05.2010

problem 1. Round_time doesn't have a return value. Therefore it's not considered as a integer (number) and is an invalid expression.
2. You call the function the wrong way. ROUND_TIME is an invalid expression. should be ROUND_TIME()
3. you probably intended to multiply round_time with 60, then substract gtimepassed. Even though the original code works, I suggest usng brackets.

pawn Код:
public ROUND_TIME()
{
    new string[265];
    format(string,sizeof(string),"Test round is over");
    SendClientMessageToAll(0x33CCFFAA,string);
    return 60;//value
}
public Timer()
{
    gTimePassed++;
  new timeleft = ((ROUND_TIME() * 60) - gTimePassed); //This is the error line :S

    new minutes = (timeleft / 60);
    new seconds = (timeleft - minutes * 60);
   
    new tmpmsg[128];
    format(tmpmsg,sizeof(tmpmsg),"%d:%d",minutes, seconds);
    TextDrawSetString(TimerCD, tmpmsg);
    TextDrawShowForAll(TimerCD);

}
Though I do not quite get what goal you have having functions like this.
Good luck