SA-MP Forums Archive
Message Box Dialog[Tutorial By Phantom] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Message Box Dialog[Tutorial By Phantom] (/showthread.php?tid=636750)



Message Box Dialog[Tutorial By Phantom] - Salarramay - 03.07.2017

I've been through The problem Of Creating a MSG Box, So i decided to figure it out for other beginners.
If This Helps please click Rep+
Lets Jump into This.

First Of All
Start a New Sample Script To Practice.

Now Type in first Line

#include <a_samp>
#include <zcmd> Optional for Easy Doing

#define MY_DIALOG //For Example

first i will show you without ZCMD include =
Go To


public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}

The Syntax


public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("Your_Command", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid, MY_DIALOG, DIALOG_STYLE_MSGBOX, "Title", "Information", "Button 1", "Button 2");

return 1;
}
return 0;
}

but if You Have ZCMD include


CMD:yourcommand(playerid)
{
ShowPlayerDialog(playerid, MY_DIALOG, DIALOG_STYLE_MSGBOX, "Title", "Information", "Button 1", "Button 2");}
return 1;
}

You Can Leave Button Space Between Quotes "" Empty To Hide A Button

Now If You Want To Add Multiple Line in MsgBox
Do The Following

ShowPlayerDialog(playerid, MY_DIALOG, DIALOG_STYLE_MSGBOX, "Title", "Information\n\
Information2\n\
Information3\n\
Information4", "Button 1", "Button 2");

Now GOTO

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

}

Now Type In Between The Function

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == MY_DIALOG)
{
if(response) //If player Presses Enter or Clicks Button
{
//Adding DialogID minus 1 Will close the dialog, You can add other Functions To It Like
//If The Command is Heal, You Can Type SetPlayerHealth(playerid, 100);
//Here instead of ShowPlayerDialog
ShowPlayerDialog(playerid, -1, DIALOG_STYLE_MSGBOX, " ", " ", " ", " ");
return 0; //This will prevent The Dialog from passing on to other functions
}

Thanks For choosing my Tutorial, I hope it Worked For You :3 If it did Please Press REP+ Button Below

ZCMD Link: https://sampforum.blast.hk/showthread.php?tid=91354


Re: Message Box Dialog[Tutorial By Phantom] - Whatname - 03.07.2017

Wrong section