[TUT] How To Make A Dialog Menu (LIST And MSGBOX Only!) -
Niixie - 21.11.2009
Hello everyone, this is my first tutorial.
Please give you good time to read it!
This is not copyed from any other tutorial, i wrote it in free hand!
I wanted to make this tuturial because when i wanted to learn it, I had to mix two other tuturials together to get the right answer
Okay, lets start.
First you need two know the difference types of Dialog you can make, there's:
- DIALOG_STYLE_MSGBOX
- DIALOG_STYLE_LIST
- DIALOG_STYLE_INPUT - (wont be made)
The MSGBOX is where you only explain something in or write a message. e.x. Welcome message on a server
The LIST is where you list up a few things to pick from, just like the old menus ( i think its easier to make than the old one )
The INPUT is where you need to write something in then press a button
Код:
ShowPlayerDialog(playerid, dialogid, dialogstyle, "welcoming title", "Your Message", "button1", "button2");
Lets take it one part at a time:
- playerid - just keep it at playerid, its the person who should see the dialog
- dialogid - you need to pick a number, like 1. You need the number so you can tell the server wich dialog it should show to the player
- dialogstyle - you need to pick wich dialog you want, a MSGBOX, LIST or INPUT as i told about before
- welcoming title - The name of the dialog, if it was a MSGBOX for welcoming message it could be "Welcome" or "Welcome to [Servername]"
- Your Message - e.x. in a MSGBOX that would be where you type e.x. "Welcome to the server, its a TDM server. CHEATERS ARRENT ALLOWED!"
- Button1 - the first button, normaly the accept button or continue button
- Button2 - the secound button, normaly the deline button or quit button
In Your message you can use:
- \n - makes a new line like pressing enter in pawno or anyother text document
- \t - makes a tap in the text like in pawno when you press the tap button
NOTE THEY ARE BOTH WITH BACKSLASH "\"!
Well, we can start making a MSGBOX, if you press continue you'll enter the server, if you press Quit you'll be kicked, thats easiest.
go in your script. find OnPlayerConnect and write it like this:
Код:
public OnPlayerConnect(playerid)
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Headline", "Welcomings message", "Continue", "Quit");
return 1;
}
Edit: Headline and Welcomings message
Now you've told your server that when the player connects to your server a dialog with MSGBOX as style will pop up and tell you what you wrote in headline and Welcoms message.
Now you need to find OnDialogResponse in your script, OnDigaloResponse means what the server should response to the to buttons that can be clicked. Type in like this:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
{
if(response)
{
SendClientMessage(playerid,0x008000FF, "Enjoy your stay!");
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "You selected 'Quit', therefore you got kicked. Goodbye!");
Kick(playerid);
}
return 1;
}
return 0;
}
Now, this tells the server that dialogid 1 was shown to the player and if he/she selected continue then he/she'll be allowed to enter the server, with the message "Enjoy your stay!". If he/she selected quit he/she got kicked with the message "You selected 'Quit', therefore you got kicked. Goodbye!".
Now you created a Dialog with style MSGBOX
And Now we'll make a Dialog with style LIST
This is the second easiest to make, all the dialogs kinda works on the same way.
Код:
ShowPlayerDialog(playerid, dialogid, dialogstyle, "List Headline", "Listed items", "button1", "button2");
Let me explain it again, word for word.
- playerid - just keep it at playerid, its the person who should see the dialog
- dialogid - you need to pick a number, like 2. You need the number so you can tell the server wich dialog it should show to the player
- dialogstyle - you need to pick wich dialog you want, a MSGBOX, LIST or INPUT as i told about in the start (Scroll up if you forgot)
- List Headline - The name of the dialog, if it was a LIST for teleports it could be "Teleports" or "[Servername]: Teleports"
- Listed Items - In a LIST dialog you make a new teleport with a new line (\n). e.x. "Unity Station \n Los Santos Police Department"
- Button1 - the first button, normaly the accept button or Select button
- Button2 - the secound button, normaly the deline button or Cancel button
Now you need to find OnPlayerCommandText so we can get the Dialog list apper with a command.
Type like this:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/Teleport", true) == 0)
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Teleport Menu", "Unity Station \n Los Santos Police Department", "Select", "Cancel");
return 1;
}
return 0;
}
Now you told the server, if a player types the command /teleport a dialog with style LIST appers where he can pick between Los Santos Police Department and Unity Station
To tell the server where Los Santos Police Department and Unity station is, find OnDialogResponse. OnDialogResponse means what the server is gonna do when the player selects something and clicks a button.
Type it like this:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 2)
{
if(response)
{
new message[256+1];
if(listitem == 0)
{
format(message, 256, "You selected Los Santos Police Department, And got teleported to there!", listitem);
SendClientMessage(playerid, 0xFFFFFFFF, message);
SetPlayerPos(playerid, 1535.5732,-1675.6609,13.3828);
}
if(listitem == 1)
{
format(message, 256, "You selected Unity Station, And got teleported to there!", listitem);
SendClientMessage(playerid, 0xFFFFFFFF, message);
SetPlayerPos(playerid, 1729.6116,-1855.1116,13.4141);
return 1;
}
}
}
return 1;
}
I'll explain what happend now.
When the player selects Los Santos Police Department or Unity Station it will send the player the message "You selected Unity Station / Los Santos Police Department, and got teleported to there!"
Remember when you wanna list more items on the list you need to add them in the OnPlayerCommandText, the way you write them in the line you MUST add them in the OnDialogResponse the same way! else it will be some mess.
The Listitem
Код:
}
if(listitem == 1)
{
Is the number of the listed item, the first on the list is numbed with 0 the second is number 1, next number 3 and so on.
Well, That'll be it from me. hope you can use it. If theres any questions then just ask away
Made by Niixie
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
[LCG]TANKER - 21.11.2009
nice guide
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Niixie - 21.11.2009
Thank you
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Luka P. - 21.11.2009
Nice, but bad indentitation at some lines.
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
dinkO14 - 21.11.2009
Excellent tutorial, this helped me
Thanks
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Niixie - 21.11.2009
Quote:
Originally Posted by Luka™
Nice, but bad indentitation at some lines.
|
If you mean in lines like these:
ShowPlayerDialog(playerid, dialogid, dialogstyle, "welcoming title", "Your Message", "button1", "button2");
where i make a space after each "," then it doesnt matter. its just so its easyer to read and looks better.
Quote:
Originally Posted by dinkO14
Excellent tutorial, this helped me
Thanks
|
That was it was ment to
So on my site its just, Great Success
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Luka P. - 21.11.2009
No not that..
I mean
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 2) // this
{ // or this, what you want, you can indent them
if(response)
{
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Niixie - 21.11.2009
I still wonders about what space you mean?
it gets no errors then compiling so, no problem
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
FUNExtreme - 21.11.2009
You should explain what "response" does. So that people know when to use it.
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Niixie - 21.11.2009
Quote:
Originally Posted by FUNExtreme
You should explain what "response" does. So that people know when to use it.
|
So now its posted. hope it'll help alot of people
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
WardenCS - 30.11.2009
what i do when i want to make 2 dialogs?:P
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Niixie - 30.11.2009
Define it? How do you mean?
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
armyoftwo - 08.12.2009
how can i create msgbox with 1 button
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Gappy - 08.12.2009
Quote:
Originally Posted by armyoftwo
how can i create msgbox with 1 button
|
It's not currently possible. Maybe in future samp version though.
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Karkanos - 18.12.2009
as I do this??
/imageshack/img94/596/samp007xh.png
Sorry for my bad english
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
RyDeR` - 18.12.2009
You should also make one with switch and case. much faster and easier.
Nice tutorial btw.
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Jakku - 18.12.2009
Nice tutorial
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Niixie - 18.12.2009
Thank you
I dont use Case myself because i think its messy
Maybe its faster but, i use DCMD to commands so the slow dialogs will be alright
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
DiddyBop - 24.12.2009
Nice guide, should be stickied!
Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!) -
Niixie - 24.12.2009
Hehe thanks