Error - 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 (
/showthread.php?tid=507350)
Error -
Ananisiki - 17.04.2014
pawn Код:
error 002: only a single statement (or expression) can follow each "case"
error 002: only a single statement (or expression) can follow each "case"
pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) +1);
SetPVarInt(playerid, "Raping", 0);
RapeAgain[playerid] = SetTimerEx("Rape", 1000*40, 0, "i", playerid);
}
else return SendClientMessage(playerid, COLOR_RED, "Nobody Close Enough To Rape.");
}
SetPlayerScore(playerid, GetPlayerScore(playerid) +1);
SetPVarInt(playerid, "Raping", 0);
RapeAgain[playerid] = SetTimerEx("Rape", 1000*40, 0, "i", playerid);
}
else
{
format(error, sizeof error, "%s (%d) Is Not Close Enough.", PlayerName(nPlayer), pID);
SendClientMessage(playerid, COLOR_RED, error);
return 1;
}
(there is more code (this is the error part)
Re : Error -
S4t3K - 17.04.2014
If you used a switch, you must use "case" statements instead of if/else.
Keep in mind that you're not forced to use brackets for cases, but if you don't, you can only proceed ONE instruction. It's the same as "if" statements.
PHP код:
new bool:var;
if(var) SendClientMessage(playerid, -1, "var is true");
else SendClientMessage(playerid, -1, "var is false");
This code is right, but this one isn't :
PHP код:
new var = 188964;
if(var != 188946) var = 188964; GivePlayerMoney(playerid, var); return 1;
else var = 0; return Kick(playerid);
// The correct code would be
new var = 188964;
if(var != 188964)
{
var = 188964;
GivePlayerMoney(playerid, var);
return 1;
}
else
{
var = 0;
return Kick(playerid);
}
Modify the code below replacing "if" and "else" by "case".