Help me (DIALOG)
#2

Okay i will try to help you but make sure next time you read SAMP Wiki before opening a thread here.

Its easy. Each dialog has its own unique id by which we identify it.

Lets start by defining a Macro for the dialog id. Every dialog should have a unique id.

pawn Код:
#define DIALOG_WEAPONS 111 //111 in this case. You have to define the id here.
Then you need to show the player the dialog of DIALOG_STYLE_LIST type. It depends upon your needs when you want to show this dialog to the player. You can make a command for it or a pickup which shows this at a particular location.

pawn Код:
ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "AK-47\nM4\nSniper Rifle", "Select", "Cancel");
playerid is the player who will see this dialog ,DIALOG_WEAPONS is the dialog id
DIALOG_STYLE_LIST is the type of dialog you want to use , in this case it is of listing items.
"Weapons" this is the title of the dialog which will be shown at the top.
"AK-47\nM4\nSniper Rifle" These are all the options shown in the dialog.
"Select", "Cancel" These are two buttons shown the dialog , in case you want one just leave the second one blank


Now we have to code what will happen when the user clicks a button with the selected item/option. This will be done under OnDialogResponse callback [public function].

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)// They pressed the first button.
    {
    switch(dialogid)
        {
        case DIALOG_WEAPONS:// Our dialog! which will be called when dialog id is 111
            {
            switch(listitem)// Checking which listitem was selected
            {
                case 0:// The first item listed
                {
                   GivePlayerWeapon(playerid, 30, 9999999); // Give playerid a AK 47 with 9999999 ammo
                }
                case 1: // The second item listed
                {
                   GivePlayerWeapon(playerid, 31, 9999999); // Give playerid a M4 Rifle with 9999999 ammo
                }
                case 2: // The third item listed
                {
                    GivePlayerWeapon(playerid, 34, 9999999); // Give playerid a Sniper Refile with 9999999 ammo
                }
            }
            }
    }
    }
    return 1;
}
Reply


Messages In This Thread
Help me (DIALOG) - by FLapJAck - 03.10.2013, 16:09
Re: Help me (DIALOG) - by Ballu Miaa - 03.10.2013, 16:26

Forum Jump:


Users browsing this thread: 1 Guest(s)