[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
#2

http://forum.sa-mp.com/index.php?topic=130168.0

what the fail?
i just wrote one...
Reply
#3

All yours is complicated and doesnt even include Dialog Response.
Why all the new stuff if you dont need it?
Waste of space imo
Reply
#4

i hadn't finished my response part, and people seemed to want a tut, so i posted what i had, if you had read the bottom of my post you would have known that.
Reply
#5

I did read it, and i decided to make one WITH the response.
Reply
#6

because i wrote it in the new topic box...

there, i just put 4 spaces in just to make you happy.
Reply
#7

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by Daren_Jacobson
http://forum.sa-mp.com/index.php?topic=130168.0

what the fail?
i just wrote one...
Yours isn't indented, a bad example for new scripters.
omg ur so sad!!! xDxDxD
Reply
#8

nothing said here, beg your pardon
Reply
#9

Quote:
Originally Posted by thuron
Quote:
Originally Posted by Seif_
Yours isn't indented, a bad example for new scripters.
omg ur so sad!!! xDxDxD he wrote one and im happy with it. if it would be a long script, ok then the identation sucks, but with this few line.. fck the identation...lolzz
Uh, i think he was talking about Daren's when he said it wasn't indented. :/
Reply
#10

wait a sec, then i was right. i mean, the one from daren is alot easyer to understand.
Reply
#11

i am so confused.
Reply
#12

just like me lolz xD
Reply
#13

lol, i was just looking at it, yours isn't indented either.
Reply
#14

Quote:
Originally Posted by Daren_Jacobson
lol, i was just looking at it, yours isn't indented either.
It must be indented if my pawno doesn't give out indentation warnings :/
And no, i didn't define my tabsize as 0.
Reply
#15

pawn only checks if it is a multiple of tabsize, so if it is 4, it could be indented 0 4 8 12... but 1 2 3 5 6 7 9... would give warnings
yours:
pawn Code:
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;
}
yours properly indented:
pawn Code:
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;
}
my edit of yours:
pawn Code:
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;
}

just wondering, what caused you to have write it as "[TUT]" in full caps, seems odd since it is an abbreviation, not a acronym. CIA (in full caps), Mrs. (first letter). I was just curious.
Reply
#16

The first 1 isn't mine.
And i wrote it in caps because i wanted to?
Reply
#17

I was just curious and what do you mean "The first 1 isn't mine"?
Reply
#18

guys shut up powersurge is good IF YOU PUT TO MANY SHIT IN UR SCRIPT IS NOT POWERSURGE PROBLEM! -.-
Reply
#19

hey darn why don't you get off this topic and pay attention to yours. There's really no need to argue. So what theres 2 of the same tutorial in my opinion this one is more easy.


- Everyone has their own opinion.
Reply
#20

Thank you BP13.
If anyone needs help with this, or something else, PM me.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)