Invalid Expression assumed Zero
#1

Hello at
Код:
else {
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;
}
Reply
#2

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;
}
Reply
#3

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
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)