How to make Dialog ?
#1

How to make Dialog ?
Reply
#2

This helped me alot when i wanted to learn, it is somuch easier than you think https://sampwiki.blast.hk/wiki/How_to_Create_a_Dialog
Reply
#3

Here is an example:

pawn Код:
if(!strcmp(cmdtext, "/drinks", true))
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "What is it that you want?", "Ban Me\nKick Me\nGive Me Money", "Skip", "Cancel");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)// They pressed the first button.
    {
    switch(dialogid)// If you only have one dialog, then this isn't required, but it's neater for when you implement more dialogs.
        {
        case 1:// Our dialog!
            {
            switch(listitem)// Checking which listitem was selected
            {
                case 0:// The first item listed
                {
                    Ban(playerid);
                }
                case 1: // The second item listed
                {
                    Kick(playerid);
                }
                case 2: // The third item listed
                {
                    GivePlayerMoney(playerid, 9999999);
                }
            }
            }
    }
    }
    return 1;
}
Reply
#4

its really easy man,like this

you have to make a define
#define DIALOG_NEW 1

if you have other dialogs that number will need to be different,you cant have more than 1 dialog with the same number.

then you just want that for like /help command,do this


PHP код:
CMD:help(playeridparams[])
{
    
ShowPlayerDialog(playeridDIALOG_NEWDIALOG_STYLE_LIST"List Of Commands","ITEM1\nITEM2\nITEM3\nITEM4\nITEM5\nITEM6\nITEM7\nITEM8""Select""Cancel");

Just like that,also you dont need to have that many listed things in there
you can also have it as a msgbox just change the DIALOG_STYLE_LIST to DIALOG_STYLE_MSGBOX
Reply
#5

Quote:
Originally Posted by NinjahZ
Посмотреть сообщение
its really easy man,like this

you have to make a define
#define DIALOG_NEW 1

if you have other dialogs that number will need to be different,you cant have more than 1 dialog with the same number.

then you just want that for like /help command,do this


PHP код:
CMD:help(playeridparams[])
{
    
ShowPlayerDialog(playeridDIALOG_NEWDIALOG_STYLE_LIST"List Of Commands","ITEM1\nITEM2\nITEM3\nITEM4\nITEM5\nITEM6\nITEM7\nITEM8""Select""Cancel");

Just like that,also you dont need to have that many listed things in there
you can also have it as a msgbox just change the DIALOG_STYLE_LIST to DIALOG_STYLE_MSGBOX
You got no dialog response?
Reply
#6

Quote:
Originally Posted by Don_Cage
Посмотреть сообщение
You got no dialog response?
Oh you want dialog response too

ok

PHP код:
if (dialogid == DIALOG_NEW//==Commands==//
    
{
        if(
response//means if they clicked left button
        
{
            if(
listitem == 0//==Help==//
            
{
                
ShowPlayerDialog(playeridDIALOG_HELP23DIALOG_STYLE_LIST"*** Help ***""/report\n/requesthelp\n/newb(ie)\n/tognewbie""Okay"" ");
            }
            if(
listitem == 1//==Account==//
            
{
                
ShowPlayerDialog(playeridDIALOG_HELP24DIALOG_STYLE_LIST"*** Account ***""/rules\n/faq\n/stats\n/inventory\n/myguns\n/buylevel\n/upgrade\n/changepass\n/killcheckpoint\n/resetupgrades(100k)""Okay"" ");
            }
            if(
listitem == 2)  //==Chat==//
            
{
                
ShowPlayerDialog(playeridDIALOG_HELP25DIALOG_STYLE_LIST"*** Chat ***""/w(hisper)\n/o(oc)\n/s(hout)\n/l(ow)\n/b\n/ad(vertise)\n/f(amily)\n/me\n/togooc\n/tognews\n/togfam\n/togwhisper""Okay""");
            }
            if(
listitem == 3)  //==Bank==//
            
{
                
ShowPlayerDialog(playeridDIALOG_HELP26DIALOG_STYLE_LIST"*** Bank ***""/balance\n/withdraw\n/deposit\n/wiretransfer\n/abalance\n/awithdraw\n/adeposit\n/awiretransfer""Okay""");
            }
            if(
listitem == 4)  //==General(1)==//
            
{
                
ShowPlayerDialog(playeridDIALOG_HELP27DIALOG_STYLE_LIST"*** General(1) ***""/pay\n/writecheck\n/cashchecks\n/charity\n/time\n/buy\n/id\n/music\n/showlicenses\n/clothes\n/mywarrants""Okay""");
            }
            if(
listitem == 5)  //==General(2)==//
            
{
                
ShowPlayerDialog(playeridDIALOG_HELP28DIALOG_STYLE_LIST"*** General(2) ***""/lock\n/skill\n/stopani\n/do\n/me\n/kill\n/buyclothes\n/droplicense\n/calculate\n/refuel\n/car\n/seatbelt\n/checkbelt""Okay""");
            }
            if(
listitem == 6)  //==General(3)==//
            
{
                
ShowPlayerDialog(playeridDIALOG_HELP29DIALOG_STYLE_LIST"*** General(3) ***""/cancel\n/accept\n/eject\n/usepot\n/usecrack\n/contract\n/service\n/families\n/joinevent\n/checkweed""Okay""");
            }
        }
    } 
NOTE:This is used from my gamemode,you see after if(listitem == 6 then show playerdialog? well them need their own defines aswell
eg:
PHP код:
#define DIALOG_NEW 1
#define DIALOG_HELP23 2
#define DIALOG_HELP24 3
#define DIALOG_HELP25 4
#define DIALOG_HELP26 5
#define DIALOG_HELP27 6
#define DIALOG_HELP28 7
#define DIALOG_HELP29 8 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)