28.10.2009, 13:26
Hello, this will show you how to make the 3 types of dialog, and how to respond to them.
Dialog 1: Message Box
Can be used for welcoming someone to a server, or for showing the rules of a server.
This example will show you how to create a welcoming box when players connect.
_________________________________________________
Let's break it up.
Here is an example of a MSG BOX
More complicated code!
Now for the Dialog Response (When they click "Continue" or "Quit"
_________________________________________________
Break it down.
_________________________________________________
Input Box
Input boxes are used for inputting text into a Dialog, like logging in...
Let's have a look at them.
Break it down..
This can be used anywhere, OnPlayerCommandText, OnPlayerConnect...
DIALOG RESPONSE
(This is for my login command, so i'll just give you my whole response)
_________________________________________________
Selection Boxes
This can be used for selecting a Quit Message, Spawning a weapon/vehicle or Teleports.
Example: Weapon Spawning
Let's break this one down.
EXAMPLE RESPONSE:
As you can see, on my list Desert Eagle is ID 1, but on the response, it's 0.
_________________________________________________
I hope this helped you, and i hope you all liked it and found it easy to understand!
Dialog 1: Message Box
Can be used for welcoming someone to a server, or for showing the rules of a server.
This example will show you how to create a welcoming box when players connect.
_________________________________________________
pawn Код:
ShowPlayerDialog([PLAYER ID],[Dialog ID],DIALOG_STYLE_MSGBOX,"[Welcoming Title]","[Your Welcome Message]""Continue","Quit");
Код:
ShowPlayerDialog - This of course is the function to show the dialog. PLAYER ID - Who do we show it to? Dialog ID - What is the ID of the Dialog? This can be completely made up as we are only using it later on. DIALOG_STYLE_MSGBOX - Well, we want the dialog to be a message box, like a welcome message. [Welcoming Title] - The title of the Dialog, this can be anything, like 'Welcome to my server!' [Your Welcome Message] - Well, we need a welcome message if you are welcoming people! Continue - Just the button they use to connect to the server Quit - In this tutorial, it will kick the player if they click Quit.
pawn Код:
ShowPlayerDialog(playerid,1338,DIALOG_STYLE_MSGBOX,"Full Metal Jacket","Welcome!\t\tHave fun on the Server!\nOwners:\t\tBen_Mitch - PowerSurge\nHead Admins:\t\tMasterD - Transporter","Play","Quit");
Код:
\n - Creates a new line \t - Creates a space, like pressing Tab in Pawno
_________________________________________________
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1338) {
if(response) {
SendClientMessage(playerid,ORANGE, "Have Fun!");
} else {
SendClientMessage(playerid, RED, "You selected 'Quit'. Goodbye!");
Kick(playerid);
}
return 1;
}
return 0;
}
Код:
public OnDialogResponse - The public function.. Not much i need to say.. if(dialogid == Dialog_ID) - Where 'Dialog_ID' is, replace with the ID of your Dialog if(response) - Did the player click the first button? (Here it's Continue) SendClientMessage - Sends the player a message you choose. else - If the player clicked button 2... (Here it's Quit) Kick(playerid); - Kicks the player. He did want to quit after all! return 1; - End of the dialog response... return 0; - End of the public function.
Input Box
Input boxes are used for inputting text into a Dialog, like logging in...
Let's have a look at them.
pawn Код:
GetPlayerName(playerid,loginname,MAX_PLAYER_NAME);
format(loginmsg,256,"Account:\t%s\n\nPlease enter your password below:",loginname);
ShowPlayerDialog(playerid,1337,DIALOG_STYLE_INPUT,"Log-in!",loginmsg,"Login","Skip");
Код:
GetPlayerName - Quite beginner to you Pawno Scripters. Does what it says. format(login..... - Used here to format the string containing the Player's name. You may replace loginmsg on the bottom line with anything you want. ShowPlayerDialog.. - DIALOG_STYLE_INPUT, The INPUT dialog style. Defines the dialog. "Log-in!" - Dialog box title. loginmsg - We formatted loginmsg above. You can replace this with your own message. Login - First button Skip - Second button
DIALOG RESPONSE
(This is for my login command, so i'll just give you my whole response)
pawn Код:
if(dialogid == Dialog_ID) {
if(response) {
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, sizeof(plname));
format(string, sizeof(string), "%s.ini", plname);
if(!fexist(string))
{
SendClientMessage(playerid, RED, "That account isn't registered.");
}
//strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
OnPlayerLogin(playerid,inputtext);
} else {
SendClientMessage(playerid, 0xFFFFFFFF, "You selected Skip");
}
return 1;.
}
Selection Boxes
This can be used for selecting a Quit Message, Spawning a weapon/vehicle or Teleports.
Example: Weapon Spawning
pawn Код:
new listitems[] = "1\tDesert Eagle\n2\tSilenced Pistol\n3\tSawn-Off Shotgun\n4\tCombat Shotgun\n5\tRPG-7\n6\tAK47\n7\tM4\n8\tLong White Vibrator\n9\tPurple Dildo\n10\tShort White Vibrator\n11\tSilver Vibrator\n12\tMac 10 (Micro Uzi)\n";
ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"List of weapons:",listitems,"Get Gun","Cancel");
Код:
new listitems[] - The items in the list. Used for indexing them so they can be used in the DialogResponse 1\tDesertEagle - The '1' is to show which List Item Number it is. In the dialog response, minus 1 from the item number. The \t was explained earlier. ShowPlayerDialog - Told you already 3 times. DIALOG_STYLE_LIST - To tell the Server that this is a LIST dialog, not an input or message box
pawn Код:
if(dialogid == 2) { //Our Dialog ID.
if(response) {
new message[256+1];
if(listitem == 0) { // List item -1
format(message, 256, "You selected 'Desert Eagle'", listitem);
SendClientMessage(playerid, 0xFFFFFFFF, message);
GivePlayerWeapon (playerid, 24, 500); // The output of the selection
} else if(listitem == 1) {
format(message, 256, "You selected 'Silenced Pistol'", listitem);
SendClientMessage(playerid, 0xFFFFFFFF, message);
GivePlayerWeapon (playerid, 23, 500);
{
_________________________________________________
I hope this helped you, and i hope you all liked it and found it easy to understand!