SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 21/11/2009, 12:11 PM   #1
Niixie
Gangsta
 
Niixie's Avatar
 
Join Date: Aug 2008
Location: Denmark
Posts: 527
Reputation: 3
Default [TUT] How To Make A Dialog Menu (LIST And MSGBOX Only!)

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

Code:
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:

Code:
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:

Code:
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.

Code:
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:

Code:
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:

Code:
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
Code:
    }
	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
__________________
Code:
 ____      __    __    __    ___       ___    __    ________
|    \    |  |  |  |  |  |  \   \     /   /  |  |  |   _____|
|     \   |  |  |  |  |  |   \   \_ _/   /   |  |  |  |
|  |\  \  |  |  |  |  |  |    \    |    /    |  |  |  |__
|  | \  \ |  |  |  |  |  |    /   _|_   \    |  |  |   __|
|  |  \  \|  |  |  |  |  |   /   /   \   \   |  |  |  |_____
|__|   \_____|  |__|  |__|  /___/     \___\  |__|  |________|
Niixie is offline   Reply With Quote
Old 21/11/2009, 12:48 PM   #2
[LCG]TANKER
Big Clucker
 
Join Date: Jul 2006
Posts: 61
Reputation: 0
Default Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!)

nice guide
[LCG]TANKER is offline   Reply With Quote
Old 21/11/2009, 02:34 PM   #3
Niixie
Gangsta
 
Niixie's Avatar
 
Join Date: Aug 2008
Location: Denmark
Posts: 527
Reputation: 3
Default Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!)

Thank you
__________________
Code:
 ____      __    __    __    ___       ___    __    ________
|    \    |  |  |  |  |  |  \   \     /   /  |  |  |   _____|
|     \   |  |  |  |  |  |   \   \_ _/   /   |  |  |  |
|  |\  \  |  |  |  |  |  |    \    |    /    |  |  |  |__
|  | \  \ |  |  |  |  |  |    /   _|_   \    |  |  |   __|
|  |  \  \|  |  |  |  |  |   /   /   \   \   |  |  |  |_____
|__|   \_____|  |__|  |__|  /___/     \___\  |__|  |________|
Niixie is offline   Reply With Quote
Old 21/11/2009, 02:37 PM   #4
Luka P.
High-roller
 
Join Date: Feb 2009
Posts: 1,556
Reputation: 12
Default Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!)

Nice, but bad indentitation at some lines.
Luka P. is offline   Reply With Quote
Old 21/11/2009, 06:08 PM   #5
dinkO14
Little Clucker
 
Join Date: Oct 2008
Posts: 3
Reputation: 0
Default Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!)

Excellent tutorial, this helped me

Thanks
dinkO14 is offline   Reply With Quote
Old 21/11/2009, 08:45 PM   #6
Niixie
Gangsta
 
Niixie's Avatar
 
Join Date: Aug 2008
Location: Denmark
Posts: 527
Reputation: 3
Default Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!)

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
__________________
Code:
 ____      __    __    __    ___       ___    __    ________
|    \    |  |  |  |  |  |  \   \     /   /  |  |  |   _____|
|     \   |  |  |  |  |  |   \   \_ _/   /   |  |  |  |
|  |\  \  |  |  |  |  |  |    \    |    /    |  |  |  |__
|  | \  \ |  |  |  |  |  |    /   _|_   \    |  |  |   __|
|  |  \  \|  |  |  |  |  |   /   /   \   \   |  |  |  |_____
|__|   \_____|  |__|  |__|  /___/     \___\  |__|  |________|
Niixie is offline   Reply With Quote
Old 21/11/2009, 08:47 PM   #7
Luka P.
High-roller
 
Join Date: Feb 2009
Posts: 1,556
Reputation: 12
Default Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!)

No not that..
I mean
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 2) // this
	{ // or this, what you want, you can indent them
		if(response)
		{
Luka P. is offline   Reply With Quote
Old 21/11/2009, 09:05 PM   #8
Niixie
Gangsta
 
Niixie's Avatar
 
Join Date: Aug 2008
Location: Denmark
Posts: 527
Reputation: 3
Default Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!)

I still wonders about what space you mean?
it gets no errors then compiling so, no problem
__________________
Code:
 ____      __    __    __    ___       ___    __    ________
|    \    |  |  |  |  |  |  \   \     /   /  |  |  |   _____|
|     \   |  |  |  |  |  |   \   \_ _/   /   |  |  |  |
|  |\  \  |  |  |  |  |  |    \    |    /    |  |  |  |__
|  | \  \ |  |  |  |  |  |    /   _|_   \    |  |  |   __|
|  |  \  \|  |  |  |  |  |   /   /   \   \   |  |  |  |_____
|__|   \_____|  |__|  |__|  /___/     \___\  |__|  |________|
Niixie is offline   Reply With Quote
Old 21/11/2009, 09:12 PM   #9
FUNExtreme
Gangsta
 
Join Date: Mar 2008
Posts: 888
Reputation: 127
Default Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!)

You should explain what "response" does. So that people know when to use it.
__________________

FUNExtreme is offline   Reply With Quote
Old 21/11/2009, 09:17 PM   #10
Niixie
Gangsta
 
Niixie's Avatar
 
Join Date: Aug 2008
Location: Denmark
Posts: 527
Reputation: 3
Default Re: [TUT] How to make a Dialog menu (LIST and MSGBOX only!)

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
__________________
Code:
 ____      __    __    __    ___       ___    __    ________
|    \    |  |  |  |  |  |  \   \     /   /  |  |  |   _____|
|     \   |  |  |  |  |  |   \   \_ _/   /   |  |  |  |
|  |\  \  |  |  |  |  |  |    \    |    /    |  |  |  |__
|  | \  \ |  |  |  |  |  |    /   _|_   \    |  |  |   __|
|  |  \  \|  |  |  |  |  |   /   /   \   \   |  |  |  |_____
|__|   \_____|  |__|  |__|  /___/     \___\  |__|  |________|
Niixie is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List style Dialog Help Tyler_Idy Help Archive 15 25/06/2010 12:10 AM
Dialog - MSGBOX Mechscape Help Archive 3 29/05/2010 10:36 AM
Help with BIG dialog in msgbox style! Posorkon Help Archive 12 12/02/2010 06:02 AM
Dialog List Help Annihalation Help Archive 2 26/10/2009 12:57 AM


All times are GMT. The time now is 08:51 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.