Dialog cases.
#1

I'm helping a friend to script, but this dialog thing is kind of weird, I'm not used to it.
Code:

pawn Код:
// This callback gets called when a player interacts with a dialog
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    // Select the proper dialog to process
    switch (dialogid)
    {
        case DialogRegister: Dialog_Register(playerid, response, inputtext); // The "Register"-dialog
        case DialogLogin: Dialog_Login(playerid, response, inputtext); // The "Login"-dialog
        }
        return 1;
}
So, how can I put these lines of code into there?

pawn Код:
if(dialogid == D_VARAV)
{
    // Do something
}

Because when I copy the lines after the 'cases', then I get error:
pawn Код:
only a single statement (or expression) can follow each "case"
Reply
#2

EDIT: Standby I will try to figure it out and then post it.
Reply
#3

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    // Select the proper dialog to process
    switch (dialogid)
    {
        case /*dialog id here*/:
        {
               //do something
        }
        case/*dialog id here*/:
        {
             //do something here
        }
        return 1;
}
Reply
#4

Sorry for double posting, wouldn't let me edit, but try this.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                // Put your stuff here.
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    // Put your stuff here.
                }
            }
        }
    }
    return 1;
}
Reply
#5

The other version would be better.. because now I have to change all the cases and the shorter the better.
Reply
#6

Use the Switch Statement it's more easy and efficient.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)