[Tutorial] How to make a Dialog!!!
#1

Dialog Tutorial...
Hello everyone,today I will be making my #1'st tutorial based on what I know allready.
I will be showing you how to make a simple dialog,with a dialog response.

Frequent Q/A
Quote:

(Q)What is a Response?
(A)It is when you click the buttons on a dialog or click on a listed item.

(Q)What is a "listed Item"?
(A)Read my tutorial and find out

(Q)Why does the code look very messy?
(A)It's because the screen cant show it well,when you copy/paste this code,it will be perfect indent.
(maybe a lil funky but hey,you can fix it when you know how...)

Lets start the actual coding now...

You will need to add 3 defines under your includes at the top of your code,to be sure just comment off 1 line then start your defines.
Код:
#define DIALOG_TEST1  1

#define DIALOG_TEST2  2

#define DIALOG_TEST3  3
Allright,now thats out of the way your gonna want to make these dialogs you just defined...
so lets make a simple one...

We will make a Command,that when used shows a dialog.
Where to place this command??
Right at the bottom of your code make a new line and then paste this code...
pawn Код:
//ZCMD CODES//
CMD:help(playerid, params[])
{
    ShowPlayerDialog(playerid, DIALOG_TEST1, DIALOG_STYLE_LIST, "Help","Listitem0\nListitem1", "Select", "Cancel");
}
That will make the dialog pop up when you are ingame and you type /help
but when you click on the box it does nothing,which is okay,but its better to have it do something right,this is called a "Response" figures huh!
This is how you make one....

Hit CTRL+F And type in the textbox that pops up "OnDialogResponse"
If and only IF you find nothing...
You will need to add this near your other public functions...
Like OnGameModeInit or OnPlayerSpawn ETC...

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}
After "{" press enter,that makes a new line to make room for your response for your dialog.

Then this is what you will put into your new line..

pawn Код:
if (dialogid == DIALOG_TEST1) //==HELP==//
    {
        if(response) //means if they clicked left button
        {
            if(listitem == 0) //==Help==//
            {
                ShowPlayerDialog(playerid, DIALOG_TEST2, DIALOG_STYLE_LIST, "TITLE", "Listitem0\nListitem1", "Okay", " ");
            }
            if(listitem == 1) //==Help==//
            {
                ShowPlayerDialog(playerid, DIALOG_TEST3, DIALOG_STYLE_LIST, "TITLE", "Listitem0\nListitem1", "Okay", " ");
            }
        }
    }
That should be near enough finished,once you have done all shown above,your dialog should work,if it dosent,let me know and I will try to help you.

also have you noticed a server that has a dialog with message box's,well know you know how its done if you read below....

The way to change it from a listbox to a message box is like this...

LISTBOX
Код:
ShowPlayerDialog(playerid, DIALOG_TEST3, DIALOG_STYLE_LIST
MESSAGEBOX
Код:
ShowPlayerDialog(playerid, DIALOG_TEST3, DIALOG_STYLE_MSGBOX
See the difference in the two? if not I will show you more easily....

Код:
A Listbox is shown like this.
DIALOG_STYLE_LIST

where as a Messagebox is shown like this.
DIALOG_STYLE_MSGBOX
If this helps please let me know cause I will think about making more.
and if anyone knows how to fix the way a code is shown propperly in the code box,please let me know.
Reply
#2

Nice!
Reply
#3

Quote:
Originally Posted by Windows32
Посмотреть сообщение
Nice!
Thanks,I hope I made some sense
Reply
#4

You should use switch(dialogid) at least teach the noobs the best way to do it, now the noobs will use a long series of if/else if which will work fine not as efficient as a switch() when you have a lot of dialogid's.
Reply
#5

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
You should use switch(dialogid) at least teach the noobs the best way to do it.
Dont you think that switchs are a lil more tough for new scripters,I think they should start at this then work towards them...Unless you would like to make a tutorial all about switch dialogs
Reply
#6

Quote:
Originally Posted by NinjahZ
Посмотреть сообщение
Dont you think that switchs are a lil more tough for new scripters,I think they should start at this then work towards them.
I don't think so, it's really no difference in difficulty I think.
Reply
#7

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
I don't think so, it's really no difference in difficulty I think.
Well I allready shown how to make dialogs,if you think they should learn switch's then maybe you could do it
Also,in my opinion these ones are really easy to make,shorter code and are basicly doing the same thing.
Reply
#8

Well if I was making dialogs I would use y_inline and y_dialogs it's the superior method but probably not good for the noobs
Reply
#9

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Well if I was making dialogs I would use y_inline and y_dialogs
Hmm
Yeah I might start to learn them ones,cause I find ******'s stuff way better,eg ZCMD is only in there cause its easy to use as a cmd processor,I use YCMD's myself
Also Y_Ini is awesome,I just remade my old gamemode from dini to yini,much better too
Reply
#10

Yes, YSI is pretty good but has some negatives as well it's pretty complex so not a lot of people will really understand it besides ****** this makes it hard for the average user add their own features/changes. But overall the pro's by far outweigh the cons.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)