SA-MP Forums Archive
error 001: expected token: ";", but found ")" - 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: error 001: expected token: ";", but found ")" (/showthread.php?tid=511599)



error 001: expected token: ";", but found ")" - SandKing94 - 06.05.2014

Errors:
PHP код:
warning 211possibly unintended assignment
error 022
must be lvalue (non-constant)
warning 215expression has no effect
error 001
expected token";"but found ")"
error 029invalid expressionassumed zero
fatal error 107
too many error messages on one line 
Script:
PHP код:
    if(RPJS(playeridstrval(params)) < 50left 50 RPJS(playeridstrval(params));
    else if(
RPJS(playeridstrval(params)) < 100left 100 RPJS(playeridstrval(params));
    else if(
RPJS(playeridstrval(params)) < 150left 150 RPJS(playeridstrval(params));
    else if(
RPJS(playeridstrval(params)) < 200left 200 RPJS(playeridstrval(params));
    else if(
RPJS(playeridstrval(params)) = 200left 0
Error line:Last line


Re: error 001: expected token: ";", but found ")" - Ghazal - 06.05.2014

Maybe because, You just made, the " 200 " RPGJS 2 times?


Re: error 001: expected token: ";", but found ")" - PrivatioBoni - 06.05.2014

You have too many brackets in some places.
Also:
pawn Код:
else if(RPJS(playerid, strval(params)) = 200) left = 0;
Should be:
pawn Код:
else if(RPJS(playerid, strval(params)) == 200) left = 0;

EDIT: actually, your brackets look OK to me though.


Re: error 001: expected token: ";", but found ")" - Konstantinos - 06.05.2014

pawn Код:
new
    amount = RPJS(playerid, strval(params);

switch (amount)
{
    case 0 .. 49: left = 50 - amount);
    case 50 .. 99: left = 100 - amount);
    case 100 ... 149: left = 150 - amount);
    case 150 .. 199: left = 200 - amount);
    case 200: left = 0;
}



Re: error 001: expected token: ";", but found ")" - SandKing94 - 06.05.2014

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
new
    amount = RPJS(playerid, strval(params);

switch (amount)
{
    case 0 .. 49: left = 50 - amount);
    case 50 .. 99: left = 100 - amount);
    case 100 ... 149: left = 150 - amount);
    case 150 .. 199: left = 200 - amount);
    case 200: left = 0;
}
What ?


Re: error 001: expected token: ";", but found ")" - Konstantinos - 06.05.2014

I used switch because it's faster than using if/else if statements. You also don't need to call RPJS so many times.

I forgot to remove the close parenthesis though:
pawn Код:
new
    amount = RPJS(playerid, strval(params);

switch (amount)
{
    case 0 .. 49: left = 50 - amount;
    case 50 .. 99: left = 100 - amount;
    case 100 ... 149: left = 150 - amount;
    case 150 .. 199: left = 200 - amount;
    case 200: left = 0;
}