16.02.2016, 16:43
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:
These are it's Parameters:
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.
Now I will make the fuction for it. The fuction would be:
This will show the Player Something like this:
Now Time for "OnDialogResponse"
Parameters:
First we will check what is the ID of the Dialog the Player Responded.
Then we will check what Button did he Pressed.
Then check what was the List Item he selected.
You will get this:
Now lets Put the Function:
Similarly we will put the other functions.
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
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[])
Код:
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 will be making a Teleport Dialog. First make a command for Showing players the Dialog e.g.
Код:
CMD:teles(playerid, params)
Код:
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Teleports", "Abondoned Airport\nSan Ferrieno Airport\nLos Santos Airport\nLas Venturas Airport","Teleport","Cancel");
Now Time for "OnDialogResponse"
Код:
OnDialogResponse(playerid, Dialogid, Response, Listitem, Inputtext[])
Код:
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
Код:
if(dialogid == 2) {
Код:
if(response) { //It means the player pressed the left Button which was "Teleport"
Код:
if(listitem == 0) { //It means he selected the first List Item which was "Abondoned Airport"
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 98) { if(response) { if(listitem == 0) {
Код:
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
Код:
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" ); }
Source: http://wiki.sa-mp.com