Quick question: Multiple dialogs
#1

Hello, I'm fairly new to scripting and I got myself into a little problem. My file has 2 dialog scripts, first one is a car spawning system, second one is a gun system. However how do I separate them in
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
Two different "ondialogresponses" seem to be fighting each other, causing a massive amount of errors.

My first dialog script ends in "return 1; }", so for the second dialog, I just carry on making a new if statement. The structure is practically the same as the first dialog - with no errors, however it causes a lot of errors. Any ideas?
Reply
#2

Firstly,you need to define the dialog ids.

DIALOG_(DIALOG NAME)

Then,you do ShowPlayerDialog(); (see wikia for the tags)

Then,

Ex:

ShowPlayerDialog(playerid,DIALOG_DIALOGNAME,DIALOG _STYLE_LIST,"DIALOG","First line\nSecondLine","Ok", "");

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid) // Lookup the dialogid
    {
        case DIALOG_(DIALOG NAME):
        {
            if(!response)
            {
                SendClientMessage(playerid, LIGHTBLUE, "You cancelled.");
                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
                {
                //DO SOMETHING FOR 1ST LINE
                }
                case 1:
                {
               //DO SOMETHING FOR 2ND LINE
                }
                // Add the rest of your listitems for dialog 1 here
}
    return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.).
}
Reply
#3

Quote:
Originally Posted by Tamer T
Посмотреть сообщение
Firstly,you need to define the dialog ids.

DIALOG_(DIALOG NAME)

Then,you do ShowPlayerDialog(); (see wikia for the tags)

Then,

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid) // Lookup the dialogid
{
case DIALOG_(DIALOG NAME):
{
if(!response)
{
SendClientMessage(playerid, LIGHTBLUE, "You cancelled.");
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
{
//DO SOMETHING FOR 1ST LINE
}
case 1:
{
//DO SOMETHING FOR 2ND LINE
}
// Add the rest of your listitems for dialog 1 here
}
return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.).
}
this will give a lot of errors.

you can check out the wiki.
It is like this
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == /*dialog id here*/)
{
//code
}
if(dialogid == /*other dialog id*/)
{
//more code
}
return 1;
}
For the wiki Click Here
Reply
#4

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
this will give a lot of errors.

you can check out the wiki.
It is like this
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == /*dialog id here*/)
{
//code
}
if(dialogid == /*other dialog id*/)
{
//more code
}
return 1;
}
Well it is possible for it to error,and actually sometimes if I add a dialog they do,but I find a way to fix them.
Reply
#5

Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)