Countdown timer giving error :s
#1

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);

}
Reply
#2

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

still having it (the error)
Reply
#4

Post the error and ROUND_TIME variable
Reply
#5

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

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

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
Reply


Forum Jump:


Users browsing this thread: