[Tutorial] How to use Dialog Styles.
#1

Ok well i've decided to make a tutorial on how to make some dialog boxes. These are the following box-styles you can use:

0 - DIALOG_STYLE_MSGBOX

1 - DIALOG_STYLE_INPUT

2 - DIALOG_STYLE_LIST

https://sampwiki.blast.hk/wiki/Dialog This is a link to SAMP wiki if you need to see what they look like!

Ok lets get started, Step 1:

Ok so have a basic command, for example a help command. I will use /info and DIALOG_STYLE_LIST:

pawn Code:
command(info, playerid, params[]) //So the start of your command
{
    {
        ShowPlayerDialog( playerid, 100, DIALOG_STYLE_LIST, "Information Menu", "Commands\nRules\n",  "Select", "Cancel" ); // Okay you can edit this and change it but let me walk you through everything!
    }
    return 1;
}
pawn Code:
ShowPlayerDialog( playerid //The ID of the player to show the dialog to.
pawn Code:
ShowPlayerDialog( playerid, 100 //100 being the number you want to assign to this dialog (max number is 32767)
pawn Code:
ShowPlayerDialog( playerid, 100, DIALOG_STYLE_LIST //The type of dialog you want it to be.
pawn Code:
ShowPlayerDialog( playerid, 100, DIALOG_STYLE_LIST, "Information Menu" //The title on the dialog
pawn Code:
ShowPlayerDialog( playerid, 100, DIALOG_STYLE_LIST, "Information Menu", "Commands\nRules\n" //What the player can select
pawn Code:
ShowPlayerDialog( playerid, 100, DIALOG_STYLE_LIST, "Information Menu", "Commands\nRules\n",  "Select", "Cancel" );// Select or cancel will be displayed at the bottom of the text box, change this to what suits you.
Ok if you understand what you are doing we will move on to Step 2:

Ok now scroll down to:

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
If you don't have it just add it in!

Now add
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 100: // Whatever number you assigned to your dialog!
        {
            if(!response)
            {
                SendClientMessage(playerid, WHITE, "Hmm ok you cancelled!");//If they select cancel
                return 1;
            }

            switch(listitem)
            {
                case 0: // The amount of cases will be determined by what the player can select! Note always start with case 0!
                {
                    SendClientMessage(playerid, WHITE, "commands go here!" );
                }
                case 1:
                {
                    SendClientMessage(playerid, WHITE, "rules go here!" );
                }
            }// You can always add more cases! If you don't want to use return 1;
        }
That's it easy! Please make sure you understand everything, also change the colours to your colours or you will get errors. Enjoy and i hope I've helped!
Reply
#2

Looks good...
Reply
#3

Excellent tut for begginers, well done.
Reply
#4

Nice tut (A for effort), but isn't this on the Wiki too?
Reply
#5

its also good to define the dialogs
Reply
#6

Quote:
Originally Posted by Raz0r1000
View Post
Nice tut (A for effort), but isn't this on the Wiki too?
Yes this is on wiki, however i used my version in my GM and also broke it down more, so it is easier to understand.
Reply
#7

Very good explained, that will be userful for newbies and well by using switch
Reply
#8

Nice work
Reply
#9

Nice tutorial and it is very usefull
Reply
#10

Very Nice, great Tutorial!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)