Message Box Dialog[Tutorial By Phantom]
#1

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
Reply
#2

Wrong section
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)