[Tutorial] How to Make Dialogs!
#1

WHAT IS IT
This is a Tutorial which will teach you how to create Dialogs with Responses.


DESCRIPTION
I have seen many people who dont know how to create Dialogs with Responses but they will now learn it using this Tutorial.


LET'S START
First I will explain How to create Dialog. "ShowPlayerDialog" is used to create a Dialog. This is the format:
Код:
ShowPlayerDialog(playerid, Dialogid, Style, Caption[], Info[], Button1[], Button2[])
These are it's Parameters:

Код:
playerid	 - The ID of the player to show the dialog to.
Dialogid 	 - The Dialog ID. Max Dialog ID is 32767.
Style  		 - The style of the dialog.
Caption		 - The Heading of The Dialog.
Info		 - The Main Text in the Dialog. Use \n for Next Line and \t for Tabulate.
Button1		 - The Text on The Left Button.
Button2		 - The Text on the Right Button.
I hope you understand it by seeing the Picture.

I will be making a Teleport Dialog. First make a command for Showing players the Dialog e.g.
Код:
CMD:teles(playerid, params)
Now I will make the fuction for it. The fuction would be:
Код:
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Teleports", "Abondoned Airport\nSan Ferrieno Airport\nLos Santos Airport\nLas Venturas Airport","Teleport","Cancel");
This will show the Player Something like this:


Now Time for "OnDialogResponse"

Код:
OnDialogResponse(playerid, Dialogid, Response, Listitem, Inputtext[])
Parameters:
Код:
playerid 	- The Player ID that responded to the Dialog.
Dialogid 	- The Dialog ID we used in ShowPlayerDialog.
Response	- 1 for left button and 0 for right button.
Listitem	- The listitem if the Dialog is a List.
Inputtext	- The Input Text if it is a Input Dialog
First we will check what is the ID of the Dialog the Player Responded.
Код:
if(dialogid == 2) {
Then we will check what Button did he Pressed.
Код:
if(response) { //It means the player pressed the left Button which was "Teleport"
Then check what was the List Item he selected.
Код:
if(listitem == 0) { //It means he selected the first List Item which was "Abondoned Airport"
You will get this:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 98) {
if(response) {
if(listitem == 0) {
Now lets Put the Function:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 98) {
if(response) {
if(listitem == 0) {

SetPlayerPos(playerid,404.0729,2464.5574,16.5000);
SendClientMessage(playerid, 0xFFFF00AA, "You Have Teleported To Abondoned Airport" ); 

} //It means End of functions of List Item 0
Similarly we will put the other functions.
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 98) {
if(response) {
if(listitem == 0) {

SetPlayerPos(playerid,404.0729,2464.5574,16.5000);
SendClientMessage(playerid, 0xFFFF00AA, "You Have Teleported To Abondoned Airport" ); 
}

if(listitem == 1) { //It means if he selected "San Ferrieno Airport"

SetPlayerPos(playerid,-1353.3026,-235.7281,14.1440);
SendClientMessage(playerid, 0xFFFF00AA, "You Have Teleported To San Ferrieno Airport" ); 
}

if(listitem == 2) { //It means if he selected "Los Santos Airport"

SetPlayerPos(playerid,1422.1212,-2541.3335,13.5469);
SendClientMessage(playerid, 0xFFFF00AA, "You Have Teleported To Los Santos Airport" ); 
}

if(listitem == 3) { //It means if he selected "Las Venturas Airport"

SetPlayerPos(playerid,1319.9559,1269.4812,10.8203);
SendClientMessage(playerid, 0xFFFF00AA, "You Have Teleported To Las Venturas Airport" ); 
}
This is my first Tutorial so please go easy on me. This is the best I could explain. I hope you guys get it. Ask me if you have any problems.

Source: http://wiki.sa-mp.com
Reply


Messages In This Thread
How to Make Dialogs! - by Compiler - 16.02.2016, 16:43
Re: How to Make Dialogs! - by AmigaBlizzard - 16.02.2016, 17:43
Re: How to Make Dialogs! - by SyS - 17.02.2016, 01:35
Re: How to Make Dialogs! - by BiosMarcel - 17.02.2016, 07:48
Re: How to Make Dialogs! - by FreAkeD - 17.02.2016, 08:21
Re: How to Make Dialogs! - by Compiler - 17.02.2016, 14:10
Re: How to Make Dialogs! - by Pottus - 18.02.2016, 17:32
Re: How to Make Dialogs! - by Vince - 18.02.2016, 19:39
Re: How to Make Dialogs! - by Pottus - 18.02.2016, 20:00
Re: How to Make Dialogs! - by Vince - 18.02.2016, 20:59

Forum Jump:


Users browsing this thread: 1 Guest(s)