[Tutorial] [TUT] How to create a dialog. (Includes responding)
#1

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.
_________________________________________________
pawn Код:
ShowPlayerDialog([PLAYER ID],[Dialog ID],DIALOG_STYLE_MSGBOX,"[Welcoming Title]","[Your Welcome Message]""Continue","Quit");
Let's break it up.

Код:
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.
Here is an example of a MSG BOX

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");
More complicated code!

Код:
\n  -  Creates a new line
\t  -  Creates a space, like pressing Tab in Pawno
Now for the Dialog Response (When they click "Continue" or "Quit"
_________________________________________________
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;
}
Break it down.
Код:
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");
Break it down..
Код:
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
This can be used anywhere, OnPlayerCommandText, OnPlayerConnect...

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");
Let's break this one down.

Код:
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
EXAMPLE RESPONSE:

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);
{
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!
Reply


Messages In This Thread
[TUT] How to create a dialog. (Includes responding) - by PowerSurge - 28.10.2009, 13:26
Re: [TUT] How to create a dialog. (Includes responding) - by Daren_Jacobson - 28.10.2009, 13:42
Re: [TUT] How to create a dialog. (Includes responding) - by PowerSurge - 28.10.2009, 13:52
Re: [TUT] How to create a dialog. (Includes responding) - by Daren_Jacobson - 28.10.2009, 13:58
Re: [TUT] How to create a dialog. (Includes responding) - by PowerSurge - 28.10.2009, 13:58
Re: [TUT] How to create a dialog. (Includes responding) - by Daren_Jacobson - 28.10.2009, 14:14
Re: [TUT] How to create a dialog. (Includes responding) - by thuron - 28.10.2009, 14:30
Re: [TUT] How to create a dialog. (Includes responding) - by thuron - 28.10.2009, 14:32
Re: [TUT] How to create a dialog. (Includes responding) - by PowerSurge - 28.10.2009, 14:38
Re: [TUT] How to create a dialog. (Includes responding) - by thuron - 28.10.2009, 14:44
Re: [TUT] How to create a dialog. (Includes responding) - by Daren_Jacobson - 28.10.2009, 15:03
Re: [TUT] How to create a dialog. (Includes responding) - by thuron - 28.10.2009, 15:10
Re: [TUT] How to create a dialog. (Includes responding) - by Daren_Jacobson - 28.10.2009, 15:14
Re: [TUT] How to create a dialog. (Includes responding) - by PowerSurge - 28.10.2009, 15:25
Re: [TUT] How to create a dialog. (Includes responding) - by Daren_Jacobson - 28.10.2009, 15:28
Re: [TUT] How to create a dialog. (Includes responding) - by PowerSurge - 29.10.2009, 12:08
Re: [TUT] How to create a dialog. (Includes responding) - by Daren_Jacobson - 30.10.2009, 00:16
Re: [TUT] How to create a dialog. (Includes responding) - by thimo - 07.11.2009, 12:21
Re: [TUT] How to create a dialog. (Includes responding) - by BP13 - 07.11.2009, 15:14
Re: [TUT] How to create a dialog. (Includes responding) - by PowerSurge - 18.11.2009, 16:25
Re: [TUT] How to create a dialog. (Includes responding) - by _Raven - 02.12.2009, 11:53
Re: [TUT] How to create a dialog. (Includes responding) - by PowerSurge - 21.12.2009, 07:09
Re: [TUT] How to create a dialog. (Includes responding) - by Deat_Itself - 21.12.2009, 07:51
Re: [TUT] How to create a dialog. (Includes responding) - by xkniives - 29.01.2010, 04:20
Re: [TUT] How to create a dialog. (Includes responding) - by Xx_OutLawZ_xX - 07.08.2010, 00:11
Re: [TUT] How to create a dialog. (Includes responding) - by lightningcrow - 20.09.2010, 13:17
Re: [TUT] How to create a dialog. (Includes responding) - by Gavin - 16.11.2010, 05:58
Re: [TUT] How to create a dialog. (Includes responding) - by Gavin - 16.11.2010, 06:00

Forum Jump:


Users browsing this thread: 9 Guest(s)