Multiple Dialog
#1

i'm creating a dialog mutiple. i have some error


Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch (dialogid)
    {
        if(dialogid == 24)
        {
            if(!response)
            {
                SendClientMessage(playerid, -1, "You have closed this dialog.");
                return 1; // We processed it
            }

            switch(listitem)
            {
                case 0: 
                {
                    new jm[170];
                    format(jm, sizeof jm, "Type your Message Here:");
                    ShowPlayerDialog(playerid, 97, DIALOG_STYLE_INPUT, "Change Message", jm, "Save", "Cancel");
                }
                case 1:
                {
                   SendClientMessage(playerid, -1, "Test 2nd dialog");
                }
            }
                
	}
    return 1;
}
Код:
(1002) : error 002: only a single statement (or expression) can follow each "case"
(1002 -- 1003) : error 029: invalid expression, assumed zero
(1025) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
command
Код:
CMD:test(playerid, params[])
{
    ShowPlayerDialog(playerid,24,DIALOG _STYLE_LIST,"DIALOG","First line\nSecondLine","Ok", "");
    return 1;
}
Reply
#2

Quote:
Originally Posted by `Compiler`
(1002) : error 002: only a single statement (or expression) can follow each "case"
Read this, and you have your error.

You need to follow switch statements up with case

so like this;



Each case represents your dialogid so you can replace case 0: with the dialog name case DIALOG_WHATEVER:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 24:
        {
            // Dialog stuff here
        }
    }
    return 1;
}
EDIT: Forgot to put in the first post that you're doing a switch statement then using the if(dialogid == dialogid way. You won't need the switch statement, because you would be switching through nothing. So if you wanted you could just knock off the switch statement, and it'd work fine.

EDIT2: Why are you formatting a string when you don't need to? You're doing something unnecessary. You should just put the text on the dialog space because if you're formatting you're using cells, and what not when you don't need them. Obviously this wouldn't make any noticeable difference when it comes to just one thing, but if you use them throughout an entire gamemode you'll more then likely notice a hinder in preformance.
Reply
#3

Quote:
Originally Posted by Wolfe
Посмотреть сообщение
Read this, and you have your error.

You need to follow switch statements up with case

so like this;



Each case represents your dialogid so you can replace case 0: with the dialog name case DIALOG_WHATEVER:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 24:
        {
            // Dialog stuff here
        }
    }
    return 1;
}
EDIT: Forgot to put in the first post that you're doing a switch statement then using the if(dialogid == dialogid way. You won't need the switch statement, because you would be switching through nothing. So if you wanted you could just knock off the switch statement, and it'd work fine.
I'm doing a multiple dialog. seems like it a single dialog
Reply
#4

Try this code instead, not tested.

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch (dialogid)
    {
        if(dialogid == 24)
        {
            if(!response)
            {
                SendClientMessage(playerid, -1, "You have closed this dialog.");
            }
            else
            {
                switch(listitem)
                {
                    case 0: 
                    {
                    new jm[170];
                    format(jm, sizeof jm, "Type your Message Here:");
                    ShowPlayerDialog(playerid, 97, DIALOG_STYLE_INPUT, "Change Message", jm, "Save", "Cancel");
                    }
                    case 1:
                    {
                    SendClientMessage(playerid, -1, "Test 2nd dialog");
                    }
                }
            }
         }    
     }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Twistedz
Посмотреть сообщение
Try this code instead, not tested.

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch (dialogid)
    {
        if(dialogid == 24)
        {
            if(!response)
            {
                SendClientMessage(playerid, -1, "You have closed this dialog.");
            }
            else
            {
                switch(listitem)
                {
                    case 0: 
                    {
                    new jm[170];
                    format(jm, sizeof jm, "Type your Message Here:");
                    ShowPlayerDialog(playerid, 97, DIALOG_STYLE_INPUT, "Change Message", jm, "Save", "Cancel");
                    }
                    case 1:
                    {
                    SendClientMessage(playerid, -1, "Test 2nd dialog");
                    }
                }
            }
         }    
     }
    return 1;
}
nope don't work
Reply
#6

Quote:
Originally Posted by DerickClark
Посмотреть сообщение
I'm doing a multiple dialog. seems like it a single dialog
Then use the method I showed and then do this;

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 0:
        {
            // Dialog ID 0
        }
        case 1:
        {
            // Dialog ID 1 here
        }
        case 2: // Dialog ID 2 here
        {
           
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by Wolfe
Посмотреть сообщение
Then use the method I showed and then do this;

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 0:
        {
            // Dialog ID 0
        }
        case 1:
        {
            // Dialog ID 1 here
        }
        case 2: // Dialog ID 2 here
        {
           
        }
    }
    return 1;
}
how i put this in the command?
Reply
#8

This format then. Sorry not on my PC to test.

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch (dialogid)
    {
        if(dialogid == 24)
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0: 
                    {
                    new jm[170];
                    format(jm, sizeof jm, "Type your Message Here:");
                    ShowPlayerDialog(playerid, 97, DIALOG_STYLE_INPUT, "Change Message", jm, "Save", "Cancel");
                    }
                    case 1:
                    {
                    SendClientMessage(playerid, -1, "Test 2nd dialog");
                    }
                }
            }
            else
            {
                   SendClientMessage(playerid, -1, "You have closed this dialog.");
            }
         }    
     }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Twistedz
Посмотреть сообщение
This format then. Sorry not on my PC to test.

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch (dialogid)
    {
        if(dialogid == 24)
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0: 
                    {
                    new jm[170];
                    format(jm, sizeof jm, "Type your Message Here:");
                    ShowPlayerDialog(playerid, 97, DIALOG_STYLE_INPUT, "Change Message", jm, "Save", "Cancel");
                    }
                    case 1:
                    {
                    SendClientMessage(playerid, -1, "Test 2nd dialog");
                    }
                }
            }
            else
            {
                   SendClientMessage(playerid, -1, "You have closed this dialog.");
            }
         }    
     }
    return 1;
}
Код:
(1002) : error 002: only a single statement (or expression) can follow each "case"
(1002 -- 1003) : error 029: invalid expression, assumed zero
(1025) : warning 209: function "OnDialogResponse" should return a value
(1026) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#10

Quote:
Originally Posted by DerickClark
Посмотреть сообщение
how i put this in the command?
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 24:
        {
            if(!response)
            {
                SendClientMessage(playerid, -1, "You have closed this dialog.");
            }
           
            ShowPlayerDialog(playerid, 97, DIALOG_STYLE_INPUT, "Change Message", "Type your message here:", "Save", "Cancel");
        }
        case 1:
        {
            SendClientMessage(playerid, -1, "This is the second dialog");
        }
        case 2:
        {

        }
    }
    return 1;
}

CMD:showdialog(playerid, params[])
{
    ShowPlayerDialog(playerid, 24, DIALOG_STYLE_INPUT, "Dialog", "First Line\nSecond Line", "Ok", "");
    return 1;
}
Also try to better your indentions, and what not it's way better to read like this;


then seeing bunched up code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)