Helpme On /go
#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


Messages In This Thread
Helpme On /go - by Rasyidmf - 06.06.2016, 07:35
Re: Helpme On /go - by semara123 - 06.06.2016, 08:01
Re: Helpme On /go - by BornHuman - 06.06.2016, 08:05

Forum Jump:


Users browsing this thread: 1 Guest(s)