Helpme On /go
#1

Can Any one fix this ?
Код:
 if(dialogid == 1555)
{
   if(!response)
   {
   SendClientMessage(playerid,red,"Canceled.");
   }
   else if(response)
   {
    switch(listitem)
	   {
		   case 0:
		   {
		   if (Zone[AIRPORT] == TEAM_ZONE_JAPAN_COLOR);
			SendClientMessage(playerid, green,"Succes Spawn There");
		   
		   }
		   else return SendClientMessage(playerid, COLOR_RED,"You Are Not Japan");
		}
	}
}
i just create a new command ! and the new command is /go . when i build that ! i got error !!
Код:
error 036: empty statement
002: only a single statement (or expression) can follow each "case"
and in here i realy dont know ! so also can you answer this and fix this ?
Reply
#2

pawn Код:
if(dialogid == 1555)
{
   if(!response)
   {return SendClientMessage(playerid,red,"Canceled.");}
   if(response)
   {
    switch(listitem)
       {
           case 0:
           {
           if (Zone[AIRPORT] == TEAM_ZONE_JAPAN_COLOR){
            SendClientMessage(playerid, green,"Succes Spawn There");
           
           }
           else return SendClientMessage(playerid, COLOR_RED,"You Are Not Japan");
           }
        }
    }
}
hope it works
Reply
#3

Quote:
Originally Posted by semara123
Посмотреть сообщение
pawn Код:
if(dialogid == 1555)
{
   if(!response)
   {return SendClientMessage(playerid,red,"Canceled.");}
   if(response)
   {
    switch(listitem)
       {
           case 0:
           {
           if (Zone[AIRPORT] == TEAM_ZONE_JAPAN_COLOR){
            SendClientMessage(playerid, green,"Succes Spawn There");
           
           }
           else return SendClientMessage(playerid, COLOR_RED,"You Are Not Japan");
           }
        }
    }
}
hope it works
That won't work. You can't use if statements under switches unless it's inside the case. That's what the error is saying he's doing.

PHP код:
if(dialogid == 1555)
{
    if(!
response)
    {
        
SendClientMessage(playerid,red,"Canceled.");
    }
    else if(
response)
    {
        switch(
listitem)
        {
            case 
0:
            {
                if(
Zone[AIRPORT] == TEAM_ZONE_JAPAN_COLOR
                   {
                       
SendClientMessage(playeridgreen,"Succes Spawn There");
                   }
            }
            default: 
SendClientMessage(playeridCOLOR_RED,"You Are Not Japan");
        }
    }

When you use a 'switch' statement the script expects you to use 'case X:'. So if you switch(listitem) then case 0 would be listitem 0, case 1 would be listitem 1, and default would be if the script didn't find a case under the statement. You can't use if statements outside of a case but inside a switch.

Example:
PHP код:
ShowPlayerDialog(playeridDIALOG_TESTDIALOG_STYLE_LIST"Select a Location""Some Location\nAnother Location\nCancel""Select""Cancel")
if(
dialogid == DIALOG_TEST)
{
    switch(
listitem)
    {
        case 
0SetPlayerPos(playerid5.04.03.0); // Would be listitem 0, A.K.A "Some Location"
        
case 1SetPlayerPos(playerid15.014.013.0); // Would be listitem 1, A.K.A "Another Location"
        
default: return 1// Would be listitem 2, A.K.A "Cancel"
    
}

Here's the wiki article on switch statements: https://sampwiki.blast.hk/wiki/Control_Structures#switch
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)