SA-MP Forums Archive
Helpme On /go - 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: Helpme On /go (/showthread.php?tid=608892)



Helpme On /go - Rasyidmf - 06.06.2016

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 ?


Re: Helpme On /go - semara123 - 06.06.2016

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


Re: Helpme On /go - BornHuman - 06.06.2016

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