OnDialogResponse, Whats Wrong?
#1

Im trying to make more than one dialog response, but i dont get it, errors:

Код:
C:\Documents and Settings\Jordi\Escritorio\Comando Ayuda\Untitled.pwn(73) : error 002: only a single statement (or expression) can follow each "case"
C:\Documents and Settings\Jordi\Escritorio\Comando Ayuda\Untitled.pwn(73 -- 74) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Jordi\Escritorio\Comando Ayuda\Untitled.pwn(94) : warning 203: symbol is never used: "MostrarDialogComandos"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(1) 
    {
        case 1:
        {
            if(!response)
            {
                MostrarDialogCancelar(playerid);
                return 1; // We processed it
            }

            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
                case 0: // Listitems start with 0, not 1
                {

                }
                ///
    switch(2)
    {
      switch(listitem) // This is far more efficient than using an if-elseif-else structure
        {
            case 0: // Listitems start with 0, not 1
            {

            }
    }


                // Add the rest of your listitems for dialog 1 here

            }

        }
        // Add the rest of your dialogs here

    }
    return 0; 
}
Reply
#2

Read this, maybe you'll understand what switch is for.
Reply
#3

Thanks, but i dont understand.
Reply
#4

this probably isnt the best example but here you go:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)// this is the switch that chooses which dialog the response was from
    {
        case dialogid: // this is where you put the id of dialog
        {
                                // this is where you put tthe code that happens when the player responds to the dialog
                       }
           }
}
Reply
#5

No problem guy, i repaired it myself, here you got a look:

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	//En caso de llamar dialog Ayuda
    switch(1) 
    {
        case 1:
        {
            if(!response)
            {
                MostrarDialogCancelar(playerid);
                return 1; // We processed it
            }

            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
                case 0: // Listitems start with 0, not 1
                {
                   MostrarDialogComandos(playerid);
                }
                 case 1: 
                {
                   MostrarDialogReglas(playerid);
                }
                 case 2: 
                {
                   MostrarDialogInformacion(playerid);
                }
                case 3: 
                {
                   MostrarDialogAdmin(playerid);
                }

                // Add the rest of your listitems for dialog 1 here

            }

        }
        // Add the rest of your dialogs here

    }
    
    //En caso de llamar dialog comandos
    switch(3)
    {
        case 1:
        {
            if(!response)
            {
                MostrarDialogCancelar(playerid);
                return 1; // We processed it
            }

            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
                case 0: // Listitems start with 0, not 1
                {
				 //NADA
                }

                // Add the rest of your listitems for dialog 1 here

            }

        }
        // Add the rest of your dialogs here

    }
    
	//En caso de llamar Dialog Ayuda
    switch(6)
    {
        case 1:
        {
            if(!response)
            {
                MostrarDialogCancelar(playerid);
                return 1; // We processed it
            }

            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
                case 0: // Listitems start with 0, not 1
                {
				 //NADA
                }

                // Add the rest of your listitems for dialog 1 here

            }

        }
        // Add the rest of your dialogs here

    }
    return 0;
}
Reply
#6

I guess its cuz you cant put switch in a switch ....



This forum requires that you wait 120 seconds between posts. Please try again in 10 seconds.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)