error 014: invalid statement; not in switch
#1

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
    {
    switch(dialogid)
        {
  case 1:// My code
    	    {
           	switch(listitem)
        	{
        	    case 0:// meh code
        	    {
                    My code
        	    }
        	    case 1: // meh code
        	    {
        	      my code
        	    }
        	    case 2: // meh code
        	    {
        	        my code
        	}
    	    }
	}
    }
    return 1;

    case 2: //
    	    {
           	switch(listitem)// 
        	{
        	    case 0:// 
        	    {
					my code
        	    }
        	    case 1: // my code
        	    {
        	        my code
        	    }
        	    case 2: // my code
        	    {
        	        my code
        	    }
        	}
    	    }
	}
    }
    return 1;
}

   case 3...
I replaced my code with my code to prevent people from stealing my code, as its not a released product yet.

The fs is in ZCMD.

at code 2;
it says "error 014: invalid statement; not in switch".
Reply
#2

You're returning 1 straight after the first case, so the next case is inaccessible.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
        switch(dialogid)
        {
            case 1:
            {
                // your code here
                return 1;
            }
            // return 1; returning 1 here will prevent anything else after this case, unless you define a new switch, but returning 1 inside the case works
            // so you're not suppose to have it there, you're suppose to have it inside the case's so it will return the value at the end of the case completion
            case 2:
            {
                // your code here
                return 1;
            }
            case 3:
            {
                // your code here
                return 1;
            }
        }
    }
    return 1;
}
Reply
#3

After removing the "return 1;" it makes no difference...
Reply
#4

Try this instead:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
    #pragma unused inputtext
    switch(dialogid) {
        case 1: {
            if(!response) {
                return 1;
            }
        }
        case 2: {
            if(!response) {
                return 1;
            }
        }
        case 3: {
            if(!response) {
                return 1;
            }
        }
        case 4: {
            if(!response) {
                return 1;
            }
        }
    }
    return 1;
}
Reply
#5

Still won't work.
Reply
#6

First, indentation is there to help you in this problem...

I was re-indenting then found this:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
        switch(dialogid)
        { // OPENING THE SWITCH!
            case 1:
            {
                switch(listitem)
                {
                    case 0:
                    case 1:
                    case 2:
                }
            }
        } // CLOSING THE SWTCH
    } // CLOSING RESPONSE
    return 1; // This return will stop the callback...

// Now, from where the hell this comes?

// You'll need another switch...

// switch(something)

case 2:
{
switch(listitem)
{
case 0:
{
my code
}
case 1:
{
my code
}
case 2:
{
my code
}
}
}
}
}
return 1;
}
Reply
#7

Are the dialog ID's correctly corresponding with the switch's? Try this instead, maybe your dialog ID's don't work perfectly:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == dialogidhere)
    {
        if(response)
        {
            // code
            return 1;
        }
    }
    if(dialogid == dialogidhere2)
    {
        if(response)
        {
            // code
            return 1;
        }
    } // and so on...
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)