[Tutorial] How to make a Dialog
#1

Dialog Tutorial :
First
Open Pawno, Then in your script you can add dialogs, lets start, first lets start with OnPlayerConnect :
pawn Code:
public OnPlayerConnect(playerid)
Write under it :
pawn Code:
ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Welcome to my SA:MP Server!","Write somethin here","Button1","Button2");
ok the dialogid, you can change it, and the dialog style Here.
Step 2 :
now OnDialogRespons !
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
Write under it :
pawn Code:
if(dialogid == 1)
{
    if(response == 1)
       {
            switch(listitem)
            {
                case 0:
                {
                 
                }
                case 1:
                {
       
                }        
               

            }

      }    
}
return 1;
}
you can add in case 1 if its the server rules the 2nd button will be "No" then he will be kicked so add this if you want to kick him if he press No button
pawn Code:
case 1:
{
 Kick(playerid);
 SendClientMessage(playerid,color,"you are kicked");
}
ok We Finish this!
lets go to another dialog style !
pawn Code:
OnPlayerConnect(playerid)
Add under it :
pawn Code:
ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST ,"Welcome to my SA:MP Server!","Write Somethin","Button1","Button2");
ok this the Style list, you can add in "write somethin" like : Our Command\n cmd here"
NOTE : \n <--- for New Line
and the Dialog Response Same as other, you can delete kick !
ok now to Dialog Style password
pawn Code:
OnPlayerConnect(playerid);
Add under it :
pawn Code:
ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD ,"Welcome","Write your password","Button1","Button2");
the response u can make it like if he did "Cancel" "Note : you can change the button2 to cancel" he will be kicked!
pawn Code:
case 1:
{
 Kick(playerid);
}
Now lets go to OnPlayerCommandText !
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
Write under it with any style dialog, dont write the pass style because hes already logged in so.
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/your command", cmdtext, true, 6) == 0)
    {
        ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Write here somethin","Blalblalba","Button1","Button2"); // you can change the dialog style so
   
        return 1;
    }
    return 0;
}
now on response :
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 2)
    {
    if(response == 1)
       {
            switch(listitem)
            {
                case 0:
                {
                 
                }
                case 1:
                {
                 
                }
               

            }

       }       
    }
    return 1;
}
you can add under case's everything like SendClientMessage and GivePlayer Gun, SetPlayerHealth Etc..
Enjoy this Tutorial, if there is something wrong, please let me know. thanks
Reply
#2

This is wrong.
pawn Code:
if(dialogid == DIALOG_STYLE_LIST)
dialogid == id, not the Dialog Style.
For example:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/your command", cmdtext, true, 6) == 0)
    {
        ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Write here somethin","Blalblalba","Button1","Button2"); // you can change the dialog style so
   
        return 1;
    }
    return 0;
}
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid) // Lookup the dialogid
    {
        case 1:
        {
            if(!response)
            {
                SendClientMessage(playerid, 0xFF0000FF, "You cancelled.");
                return 1; // We processed it
            }
 
            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
                case 0: // Listitems start with 0, not 1
                {
                    // What should happen when they click on the first item?
                }
                case 1:
                {
                    // And the second item?
                }
                case 2:
                {
                    // We can keep going on here ;)
                }
                // Add the rest of your listitems for dialog 1 here
 
            }
 
        }
        // Add the rest of your dialogs here
 
    }
    return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.).
}
It should return 0
Reply
#3

but it work with the 2 i test it, i gonna fix it here, thanks so.
Reply
#4

i fixed it
Reply
#5

gonna add more commands to it soon
ops soz for spam :/
Reply
#6

Not really a tutorial, more of a copy paste thread where the code is devided over multiple blocks.
Reply
#7

rofl
Reply
#8

Guys help , i tryed many of your topics , but it don't help me . I compile it , i get no errors , no warnings , but when dialog pop out , and i chose the thing i wanna do , nothing happends , it just closes . help please
Reply
#9

You should explain more, not just add this there and that here..etc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)