Hello guys, before I start this tutorial, you should have a include called
ZCMD because we'll use it later.
Remember to put ZCMD:
#include <a_samp>
#include <zcmd>
First, if you've ZCMD now, please find this and remove it:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
After that, make a new command with your newly ZCMD. >.>
CMD:dialog(playerid,params[])
{
/*We'll learn here!*/
return 1;
}
Alright, if you've copied the "/*We'll learn here*/", remove it, and make a ShowPlayerDialog.
CMD:dialog(playerid,params[])
{
ShowPlayerDialog();
return 1;
}
No, don't compile it yet. Now let's see the ShowPlayerDialog's parameters:
(playerid, dialogid, style, caption[], info[], button1[], button2[])I will explain it here now.
"playerid" - The ID of the player to show the dialog to. (Obviously to you)
"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. (4 types of dialog, "DIALOG_STYLE_MSGBOX, DIALOG_STYLE_LIST, DIALOG_STYLE_INPUT,
DIALOG_STYLE_PASSWORD *not recommended*)
"caption[]" - The title of the dialog.
"info" - Its info in it.
"button1[]" - The first button, for example, "yes".
"button2[]" - The second button, for example, "no", you can also use "" if you want to hide it.
Now, you've understand it, if you don't understand it, read it again.
Alright, let's make a dialog!
CMD:dialog(playerid,params[])
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Dialog", "Hello, this is my first dialog", "Yay!", "Boo!");
return 1;
}
This is an example dialog without response. (DIALOG_STYLE_MSGBOX is the suitable one)
Now, let's make a dialog with response. (I suck at this)
CMD:dialog2(playerid,params[])
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Dialog", "Response 1\nResponse 2\nResponse 3", "Choose", "Exit");
return 1;
}
Alright, after creating it, now search for this:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
Now, let's make a response.
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 2:
{
if(response)
{
switch(listitem)
{
case 0: return SendClientMessage(playerid, 0xFFFFFFAA, "Response 1");
case 1: return SendClientMessage(playerid, 0xFFFFFFAA, "Response 2"), DestroyVehicle(1); //With two response in return
case 2: return SendClientMessage(playerid, 0xFFFFFFAA, "Response 3"), SetPlayerPos(playerid, 0.0, 0.0, 3.0),DestroyVehicle(2); //With 3 response in return
}
}
}
}
return 1;
}
*DestroyVehicle is just giving an example!
Now, you're done, good luck in scripting OnPlayerDialog (You will only use DIALOG_STYLE_MSGBOX and LIST only, that's why I don't give a tutorial in INPUT and PASSWORD, not really know with INPUT and PASSWORD)