[Tutorial] Dialog Types and Other stuffs
#1

Hello , I am going to Explain how to make Random Spawns Through Dialog box and how to make them Response through in it..

What is Dialog box?

Dialog box is nothing but , a source where you can add a Dialog popup on a players screen by a Key or a Command text , It is usually used to make Login / Register System , Spawning Car's / Player's Skin , Commands info's , Server Info , Credits , Server Information and much more by your Creativity.

So, What types of Dialog box exists in SA-MP scripting ?
-List Dialog : To show a list of stuffs , that you want the player to choose and have 2 buttons to reply.
-Message Box Dialog : This is a simple one. It just is a textbox with two buttons no input no different choices just two buttons to process.
-Input Dialog : This dialog will have a line for input. (as the name implies).

List Dialog

Ok , So how to make a List Dialog and make the player to response them..

It's Easy , Let me Explain.

Код:
Here we Use , some called 
ShowPlayerDialog(playerid , DIALOG_NAME , DIALOG_TYPE,"DIALOG_CAPTION",DIALOG_INFO,"BUTTON1","BUTTON2");
Here Let me Explain you every Component -
playerid - The id of the player who type the Command.
DIALOG_NAME - You can write a number here , to specify the DIALOG.. Orelse you can make it in this way
new DIALOG_NAME NumberOfList
Example - new DIALOG_CARS 200
DIALOG_TYPE - As this is a list dialog , we put here - DIALOG_STYLE_LIST.
DIALOG_CAPTION - The name you want to put on the DIALOG Top.
DIALOG_INFO - The info you want to add there , Example - Infernus\nBullet\nCheetah\nBanshee , etc ....and it will show line wise.
BUTTON1 - It is the True button , it will make the Thing comes on , for example , if a player press on Infernus and press the button1 he gets the infernus. Mostly People name it , "SELECT".
BUTTON2 - This will make the action false. Mostly People name it , "CLOSE" or "CANCEL".

To make a response we must use " public OnDialogResponse(playerid) "

So this was what we can understand with DIALOG List type.
For a Example - I make a Gun Dialog.

new DIALOG_WEAPONS 3
Using ZCMD
Код:
CMD:guns(playerid,params[])
{
         ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Desert Eagle\nAK-47\nCombat Shotgun", "Select", "Close");
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_WEAPONS)
    {
        if(response) // If they clicked 'Select' or double-clicked a weapon
        {
            // Give them the weapon
            switch(listitem)
            {
                case 0: GivePlayerWeapon(playerid, WEAPON_DEAGLE, 14); // Give them a desert eagle
                case 1: GivePlayerWeapon(playerid, WEAPON_AK47, 120); // Give them an AK-47
                case 2: GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 28); // Give them a Combat Shotgun
            }
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }
 
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
This was a small example for Dialog List Type.. And it works WOW.. Now we go on with the Message type Dialog Box

Message Box Dialog

Everything is same , You just show the guy a message on his Screen , And 2 Options at the same time , As this is a message box you can make it , "Yes" and "No" , orelse if you want a single button , leave one as , " " and "Close"
This will show only 1 option "Close".

Example - We ask them about the Rules.
#define COLOR_RED 0xAA3333AA
new DIALOG_RULES 1
Код:
CMD:rules(playerid,params[])
{
         ShowPlayerDialog(playerid, DIALOG_RULES, DIALOG_STYLE_MSGBOX, "Server Rules", "- No Cheating\n- No Spamming\n- Respect the commands\nNo BUGS\nNo BUG abuse\n\nDo you agree to these rules?", "Yes", "No");
}
And in OnDialogResponse

we type
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_RULES)
    {
        if(response) // If they clicked "Yes" or if he press ENTER
        {
            SendClientMessage(playerid, COLOR_GREEN, "Thank you for agreeing to the server rules!");
        }
        else // Prssed ESC or clicked cancel
        {
            SendClientMessage(playerid, COLOR_RED, "You MUST agree to the server rules to play here.");
            
        }
        return 1; 
    }
 
    return 0; 
}
And WoW we are done.

Now here is the Input type Dialog.

Input Dialog
So this is same Aswell, Put here it goes as Follows
Код:
Here we Use , some called 
ShowPlayerDialog(playerid , DIALOG_NAME , DIALOG_TYPE,"DIALOG_CAPTION",DIALOG_INFO,"BUTTON1","BUTTON2");
Here Let me Explain you every Component -
playerid - The id of the player who type the Command.
DIALOG_NAME - You can write a number here , to specify the DIALOG.. Orelse you can make it in this way
new DIALOG_NAME NumberOfList
Example - new DIALOG_LOGIN_4
DIALOG_TYPE - As this is a list dialog , we put here - DIALOG_STYLE_INPUT.
DIALOG_CAPTION - The name you want to put on the DIALOG Top.
DIALOG_INFO - The Message you want to DISPLAY.
BUTTON1 - It is the True button , it will make the Thing comes on , for example , if a player press on Infernus and press the button1 he gets the infernus. Mostly People name it , "LOGIN".
BUTTON2 - This will make the action false. Mostly People name it , "CANCEL".

For any Easy Explanation let me explain you with an example -

Here i am going to make a Input box , that ask for age and save it.

Код:
enum pInfo
{
	pAge
}
That was simple enough.. to understand now let us make a " new " variable.
Код:
new pData[MAX_PLAYERS][pInfo];
Here we made a " new " variable.
Now we make a Define for our Dialog.
Код:
#define DIALOG_AGES 1
Now let's go with the Command, i use ZCMD.

Код:
CMD:age(playerid,params[])
{
	ShowPlayerDialog(playerid, DIALOG_AGES, DIALOG_STYLE_INPUT, "AGE", "Enter your age", "Done"," ");
}
Ok i choosed the dialog stype [ INPUT ] and the caption as age , and the data as " Enter your age " , and only one option " Done ".
Now on Dialog Response
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == DIALOG_AGES]
	{
	    if(response)
	    {
			 pData[playerid][pAge] = strval(inputtext); // This will save the age.
	    }
	}
	return 1;
}
Ok , now a command to check the age.
Код:
CMD:checkage(playerid,params[])
{
	SendClientMessage(playerid,0x0000BBAA,"Your age is (pData[playerid][pAge])"); //The Color indicates Blue , and now the age will be Displayed.
}
And WOW , we are Done , If you again want to change the age , you need to do nothing , it saves the age automatically.

So , this is how we work with DIALOG.
I made this tutorial , to make it more Easy, If someone don't Understand Anything from other Tutorials, they can understand from here.

Thanks.
P.S - If i am wrong anywhere Please inform me , i will correct myself.
Reply


Messages In This Thread
Dialog Types and Other stuffs - by fuckingcruse - 27.03.2015, 12:07
Re: Dialog Types and Other stuffs - by LazyB0y - 27.03.2015, 12:52
Re: Dialog Types and Other stuffs - by CalvinC - 27.03.2015, 13:14
Re: Dialog Types and Other stuffs - by PowerPC603 - 27.03.2015, 13:23
Re: Dialog Types and Other stuffs - by fuckingcruse - 27.03.2015, 13:25
Re: Dialog Types and Other stuffs - by CalvinC - 27.03.2015, 13:40
Re: Dialog Types and Other stuffs - by SickAttack - 27.03.2015, 14:30
Re: Dialog Types and Other stuffs - by fuckingcruse - 27.03.2015, 14:56
Re: Dialog Types and Other stuffs - by SnoopDy - 27.03.2015, 16:21
Re: Dialog Types and Other stuffs - by CalvinC - 27.03.2015, 16:35

Forum Jump:


Users browsing this thread: 1 Guest(s)