Bracket Error
#1

Hello, i think i have an bracket error on this line: case DIALOG_BUY_CLASSES: it show me this errors:

error 014: invalid statement; not in switch
warning 215: expression has no effect
error 001: expected token: ";", but found ":"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Код:
	case DIALOG_BUY_CLASSES:
		{
		    if(response)
		    {
				if(team[playerid] == TEAM_HUMAN)
			    {
					if(pInfo[playerid][SkinChanges] >= 1)
					{
						switch(listitem)
						{
							case 0: if(pInfo[playerid][pCookies] >= 10) pInfo[playerid][pCookies] -= 10,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ENGINEER,setClass(playerid); else { SendCookieError(playerid,10); }
							case 1: if(pInfo[playerid][pCookies] >= 10) pInfo[playerid][pCookies] -= 10,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = SWAT,setClass(playerid); else { SendCookieError(playerid,10); }
							case 2: if(pInfo[playerid][pCookies] >= 50) pInfo[playerid][pCookies] -= 50,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = HEAVYSHOTGUN,setClass(playerid); else { SendCookieError(playerid,50); }
							case 3: if(pInfo[playerid][pCookies] >= 10) pInfo[playerid][pCookies] -= 10,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ADVANCEDMEDIC,setClass(playerid); else { SendCookieError(playerid,10); }
							case 4: if(pInfo[playerid][pCookies] >= 15) pInfo[playerid][pCookies] -= 15,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ADVANCEDENGINEER,setClass(playerid); else { SendCookieError(playerid,15); }
							case 5: if(pInfo[playerid][pCookies] >= 15) pInfo[playerid][pCookies] -= 15,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = FEDERALAGENT,setClass(playerid); else { SendCookieError(playerid,15); }
							case 6: if(pInfo[playerid][pCookies] >= 100) pInfo[playerid][pCookies] -= 100,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = KICKBACK,setClass(playerid); else { SendCookieError(playerid,100); }
							case 7: if(pInfo[playerid][pCookies] >= 80) pInfo[playerid][pCookies] -= 15,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ADVANCEDSCOUT,setClass(playerid); else { SendCookieError(playerid,80); }
							case 8: if(pInfo[playerid][pCookies] >= 20) pInfo[playerid][pCookies] -= 20,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = E_ENGINEER,setClass(playerid); else { SendCookieError(playerid,20); }
							case 9: if(pInfo[playerid][pCookies] >= 100) pInfo[playerid][pCookies] -= 100,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = DOCTOR,setClass(playerid); else { SendCookieError(playerid,100); }
						}
					}
					else return SendClientMessage(playerid,-1,""chat""COL_RED" You are not allowed to change your class anymore!");
				}
				else return SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You must be a human to buy weapons");
				}
 }
 }
 }
 }

	return 1;
}
Can you help me, please?
Reply
#2

An advise is to indent your code and see if there're more or less brackets. Look at the end.
pawn Код:
case DIALOG_BUY_CLASSES:
{
    if(response)
    {
        if(team[playerid] == TEAM_HUMAN)
        {
            if(pInfo[playerid][SkinChanges] >= 1)
            {
                switch(listitem)
                {
                    case 0: if(pInfo[playerid][pCookies] >= 10) pInfo[playerid][pCookies] -= 10,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ENGINEER,setClass(playerid); else { SendCookieError(playerid,10); }
                    case 1: if(pInfo[playerid][pCookies] >= 10) pInfo[playerid][pCookies] -= 10,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = SWAT,setClass(playerid); else { SendCookieError(playerid,10); }
                    case 2: if(pInfo[playerid][pCookies] >= 50) pInfo[playerid][pCookies] -= 50,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = HEAVYSHOTGUN,setClass(playerid); else { SendCookieError(playerid,50); }
                    case 3: if(pInfo[playerid][pCookies] >= 10) pInfo[playerid][pCookies] -= 10,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ADVANCEDMEDIC,setClass(playerid); else { SendCookieError(playerid,10); }
                    case 4: if(pInfo[playerid][pCookies] >= 15) pInfo[playerid][pCookies] -= 15,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ADVANCEDENGINEER,setClass(playerid); else { SendCookieError(playerid,15); }
                    case 5: if(pInfo[playerid][pCookies] >= 15) pInfo[playerid][pCookies] -= 15,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = FEDERALAGENT,setClass(playerid); else { SendCookieError(playerid,15); }
                    case 6: if(pInfo[playerid][pCookies] >= 100) pInfo[playerid][pCookies] -= 100,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = KICKBACK,setClass(playerid); else { SendCookieError(playerid,100); }
                    case 7: if(pInfo[playerid][pCookies] >= 80) pInfo[playerid][pCookies] -= 15,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ADVANCEDSCOUT,setClass(playerid); else { SendCookieError(playerid,80); }
                    case 8: if(pInfo[playerid][pCookies] >= 20) pInfo[playerid][pCookies] -= 20,pInfo[playerid][SkinChanges] -= 1,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = E_ENGINEER,setClass(playerid); else { SendCookieError(playerid,20); }
                    case 9: if(pInfo[playerid][pCookies] >= 100) pInfo[playerid][pCookies] -= 100,pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = DOCTOR,setClass(playerid); else { SendCookieError(playerid,100); }
                }
            }
            else return SendClientMessage(playerid,-1,""chat""COL_RED" You are not allowed to change your class anymore!");
        }
        else return SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You must be a human to buy weapons");
    }
}
}
}
}
Reply
#3

what do you mean? i dont understand, even if i remove some brackets it wont work.
Reply
#4

Your cases are also incorrect.

pawn Код:
case 0: Something();
case 1:
{ // <-
    Something();
    Something_Else();
} // <-
When you have more than 1 function to use, it needs to be in a { }.
Reply
#5

It working for me so, i just search help with this, can you help me?
Reply
#6

Please help me..
Reply
#7

If i delete this code then the error comes on an other for example: case DIALOG_TEST:

But why how can i fix that?
Reply
#8

Or is it an OnPlayerResponse bug?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)