[Tutorial] Dialogs Usages
#1

Hello.This is my first tutorial.
In this tutotial i want to show you 3 Dialog Styles and how to use them
Code:
0 - DIALOG_STYLE_MSGBOX

1 - DIALOG_STYLE_INPUT

2 - DIALOG_STYLE_LIST
Ok. Lets start it

In all Dialog styles you can use colours:

Code:
{FFFFFF}White
{F3FF02}Yellow
{FFAF00}Orange
{F81414}Red
{0049FF}Blue
{B700FF}Purple
{00FFEE}Cyan
{6EF83C}Green
{0E0101}Black

Or go to  to make your own colour<<<@!1!@>>>
You can use Colours in all 3 Dialog Styles
------------------------------------------------------------------------------------------------
First Style - DIALOG_STYLE_MSGBOX
You can use MSGBOX for stats,rules,other.
Dialog Parameters
pawn Code:
playerid The ID of the player to show the dialog to.

dialogid An ID to assign this dialog to, so responses can be processed. Max dialogid is 32767. Using negative values will close any open dialog.

style The style of the dialog.

caption[] The title at the top of the dialog. The length of the caption can not exceed more than 64 characters before it starts to cut off.

info[] The text to display in the dialog. Use \n to start a new line and \t to tabulate.

button1[] The text on the left button.

button2[] The text on the right button. Leave it blank to hide it.




Returns This function doesn't return a specific value
Example of using DIALOG_STYLE_MSGBOX
pawn Code:
if (strcmp("/dialog", cmdtext, true, 10) == 0)
    {
    ShowPlayerDialog(playerid,1, DIALOG_STYLE_MSGBOX, "Type something here","This is dialog test.\nSecond Line\nThird line\n{FFAF00}Orange colour", "Cancel", "Continue")return 1;
    }
To make a new line you need to use \n.
Also u can use \t to tabulate.


If you want to make long dialog but you get errors cuz its too long try to use Dialog Streamer

pawn Code:
if (strcmp("/sdialog", cmdtext, true, 10) == 0)
    {
        new HugeString[1024];
        format(HugeString, sizeof(HugeString), "{FFFFFF}White Colour\n{F3FF02}Yellow Colour\n{F81414}Red Colour\n ");
        format(HugeString, sizeof(HugeString), "%s{0049FF}Blue Colour\n{B700FF}Purple colour\n{00FFEE}Cyan Colour\n{6EF83C}Green Colour \n{FFC0CB}Pink Colour\n{0E0101}Black Colour", HugeString);
        ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "Dialog Streamer", HugeString, "OK", "");
        return 1;
    }
------------------------------------------------------------------------------------------------

DIALOG_STYLE_LIST
You can use this dialog styles when you buy vehicles,weapons,other
In this style you can use colours too.

Example of using DIALOG_STYLE_LIST
Write your command to select some weapons.
Add your weapon list,and now go to " OnDialogResponse "
Don't forgot to add \n

DIALOG_STYLE_LIST Parameters:

pawn Code:
playerid The ID of the player who responded to the dialog box.

dialogid The ID of the dialog the player responded to, assigned in ShowPlayerDialog.

response 1 for first button and 0 for second button

listitem The ID of the list item selected by the player.

inputtext[] The text entered into the input box by the player or the selected list item text.
pawn Code:
if (strcmp("/dweapons", cmdtext, true, 10) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{00FFEE}Select weapon","{F3FF02}Sawn-Off\n{F81414}Minigun\n{0049FF}RPG\n{B700FF}Dildo\n{6EF83C}Flowers\n{FFC0CB}Desert Eagle","OK","Cancel");
        return 1;
    }
You always need to start from " if(listitem == 0) "
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
{
    if(!response) return SendClientMessage(playerid, 0xFF0000FF, "You canceled!");
}
    if(listitem == 0)
{
    GivePlayerWeapon(playerid,26,500);
    SendClientMessage(playerid,0xFFFFFFFF,"You recivied a Sawn-Off Shotgun");
    return 1;
}
    if(listitem == 1)
{
    GivePlayerWeapon(playerid,38,500);
    SendClientMessage(playerid,0xFFFFFFFF,"You recivied a Minigun");
    return 1;
}
    if(listitem == 2)
{
    GivePlayerWeapon(playerid,35,500);
    SendClientMessage(playerid,0xFFFFFFFF,"You recivied a RPG");
    return 1;
}
    if(listitem == 3)
{
    GivePlayerWeapon(playerid,10,500);
    SendClientMessage(playerid,0xFFFFFFFF,"You recivied a Dildo");
    return 1;
}
    if(listitem == 4)
{
    GivePlayerWeapon(playerid,14,500);
    SendClientMessage(playerid,0xFFFFFFFF,"You recivied Flowers");
    return 1;
}
    if(listitem == 5)
{
    GivePlayerWeapon(playerid,24,500);
    SendClientMessage(playerid,0xFFFFFFFF,"You recivied a Desert Eagle");
    return 1;
}
    return 0;
}

------------------------------------------------------------------------------------------------
3 - DIALOG_STYLE_INPUT
You can use DIALOG_STYLE_INPUT For Register/login sistems

Register/login sistem by Kwarde

http://forum.sa-mp.com/showthread.ph...OG_STYLE_INPUT

Good luck
Reply
#2

Well done tutorial, it will help me in couple of situations ill do. Thanks and keep good work
Reply
#3

Very nice for beginners
Reply
#4

Quote:

You will always need to start from "if(listitem == 0)"

Wrong. You can start with 'if(listitem == 1)' or 'if(listitem == 5)'. It doesn't matter with what you start.
Also, you can use:
pawn Code:
switch(listitem)
{
    case 0: //Do something
    case 1: //Do something
    case 2: //Do something
    // Etc
    default: //None of the cases above
}
Which equals:
pawn Code:
if(listitem == 0) //Do something
if(listitem == 1) //Do something
if(listitem == 2) //Do something
// Etc
if(listitem != 0 && listitem != 1 && listitem != 2) // None of the cases above
Btw,
Quote:

Register/login sistem by Kwarde
http://forum.sa-mp.com/showthread.ph...OG_STYLE_INPUT
Eh that's not a register/login system. That are "dialog tips"
But this is a nice tutorial though
Reply
#5

Quote:
Originally Posted by Kwarde
View Post
Wrong. You can start with 'if(listitem == 1)' or 'if(listitem == 5)'. It doesn't matter with what you start.
Also, you can use:
pawn Code:
switch(listitem)
{
    case 0: //Do something
    case 1: //Do something
    case 2: //Do something
    // Etc
    default: //None of the cases above
}
Which is equal to
pawn Code:
if(listitem == 0) //Do something
if(listitem == 1) //Do something
if(listitem == 2) //Do something
// Etc
if(listitem != 0 && listitem != 1 && listitem != 2) // None of the cases above
Btw,

Eh that's not a register/login system. That are "dialog tips"
But this is a nice tutorial though
Yeah but if they want to make a weapon dialog
They need to start from 0 if they want to get guns from first listitem
Btw thanks
Reply
#6

Ah so. I think you should say "Counting start from 0. So for the first option from the list, use listitem == 0". Or atleast something smilar to that
Reply
#7

Good, nice work
Reply
#8

Nice tut
Reply
#9

Thank you all.
I will try to add more tutorials
Reply
#10

Great information for beginners. Well done.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)