Invalid Expression assumed Zero - 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: Invalid Expression assumed Zero (
/showthread.php?tid=447119)
Invalid Expression assumed Zero -
Blackazur - 28.06.2013
Hello at
i have this error: invalid expression assumed zero. How to fix it?
Код:
CMD:spec(playerid, params[])
{
if(pInfo[playerid][pLogged] == 1)
{
if(pInfo[playerid][pAdminLevel] >= 1)
{
if(team[playerid] == TEAM_ADUTY)
{
if(!strlen(params)) return SendClientMessage(playerid,-1,""chat""COL_LGREEN" /spec [id]");
new giveid=strval(params);
if(!IsPlayerConnected(giveid) || giveid==playerid)return SendClientMessage(playerid,-1,""chat""COL_RED" Invalid ID");
TogglePlayerSpectating(playerid,1);
switch(GetPlayerState(giveid))
{
case 2,3:PlayerSpectateVehicle(playerid,GetPlayerVehicleID(giveid));
case 0,1,7,8,4:PlayerSpectatePlayer(playerid,giveid);
case 9:return SendClientMessage(playerid,-1,""chat""COL_RED" You cant spec this player");
}
new MyString[128];
format(MyString,sizeof MyString, "{FFFFFF}» {FFFF00}You are now spectating %s! Type /specoff to stop", PlayerName(giveid));
SendClientMessage(playerid, -1, MyString);
SetPVarInt(playerid,"spect",giveid);
SetPVarInt(giveid,"spec",playerid);
}
}
else {
SendClientMessage(playerid,-1,""chat""COL_WHITE" SERVER: Unknown command.");
}
}
else {
SendClientMessage(playerid,-1,""chat" You are not logged in!");
Kick(playerid);
}
else {
SendClientMessage(playerid,-1,""chat""COL_RED" You must be on duty to use this command.");
Kick(playerid);
}
return 1;
}
AW: Invalid Expression assumed Zero -
HurtLocker - 28.06.2013
try this:
pawn Код:
CMD:spec(playerid, params[])
{
if (pInfo[playerid][pLogged] == 1)
{
if (pInfo[playerid][pAdminLevel] >= 1)
{
if (team[playerid] == TEAM_ADUTY)
{
if(!strlen(params)) return SendClientMessage(playerid,-1,""chat""COL_LGREEN" /spec [id]");
new giveid=strval(params);
if(!IsPlayerConnected(giveid) || giveid==playerid)return SendClientMessage(playerid,-1,""chat""COL_RED" Invalid ID");
TogglePlayerSpectating(playerid,1);
switch(GetPlayerState(giveid))
{
case 2,3:PlayerSpectateVehicle(playerid,GetPlayerVehicleID(giveid));
case 0,1,7,8,4:PlayerSpectatePlayer(playerid,giveid);
case 9:return SendClientMessage(playerid,-1,""chat""COL_RED" You cant spec this player");
}
new MyString[128];
format(MyString,sizeof MyString, "{FFFFFF}» {FFFF00}You are now spectating %s! Type /specoff to stop", PlayerName(giveid));
SendClientMessage(playerid, -1, MyString);
SetPVarInt(playerid,"spect",giveid);
SetPVarInt(giveid,"spec",playerid);
}
else
{
SendClientMessage(playerid,-1,""chat""COL_RED" You must be on duty to use this command.");
Kick(playerid);
}
}
else SendClientMessage(playerid,-1,""chat""COL_WHITE" SERVER: Unknown command.");
}
else
{
SendClientMessage(playerid,-1,""chat" You are not logged in!");
Kick(playerid);
}
return 1;
}
Respuesta: Invalid Expression assumed Zero -
CIzaquita - 28.06.2013
Its cause because the tabulation are wrong, make sure that the tabulation coincide whit the if, e.g:
pawn Код:
if(condition)
{
if(condition)
{
//Something
}
else
{
//Something
}
}
else
{
//Something here
}