[HELP]Re-making dialog
#6

Let's say that's your command to open the menu to buy guns, be sure to #define the name of the dialog like #define GUN_MENU.
pawn Код:
CMD:buygun(playerid, params[])
{
    ShowPlayerDialog(playerid, GUN_MENU, DIALOG_STYLE_LIST, "Ammu Nation", "Deagle\nM4 Assault Rifle", "Buy", "Cancel");
}
And on dialog response put this.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == BUY_GUN)
    {
        if(response) // If they clicked 'Select' or double-clicked a weapon
        {
            if(listitem == 0)
            {
                if(GetPlayerCash(playerid) >= 1000)
                {
                    GivePlayerValidWeapon(playerid, 24, 100); // Weapon ID, Ammo
                    GivePlayerCash(playerid, -1000);
                    SendClientMessageEx(playerid, COLOR_WHITE, "You have purchased a Desert Eagle!");
                    return 1;
                }
                else
                {
                    SendClientMessageEx(playerid, COLOR_WHITE, "You can't afford that weapon!");
                    return 1;
                }
            }
            if(listitem == 1)
            {
                if(GetPlayerCash(playerid) >= 1000)
                {
                    GivePlayerValidWeapon(playerid, 31, 100); // Weapon ID, Ammo
                    GivePlayerCash(playerid, -1000);
                    SendClientMessageEx(playerid, COLOR_WHITE, "You have purchased an M4 Assasult Rifle!");
                    return 1;
                }
                else
                {
                    SendClientMessageEx(playerid, COLOR_WHITE, "You can't afford that weapon!");
                    return 1;
                }
            }
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }

    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
I tryed it to explain it to you somehow, but check this if you wish https://sampwiki.blast.hk/wiki/OnDialogResponse
Reply


Messages In This Thread
[HELP]Re-making dialog - by darkokan - 05.10.2014, 16:31
Re: [HELP]Re-making dialog - by YanLanger - 05.10.2014, 17:14
Re: [HELP]Re-making dialog - by dionisak0s - 05.10.2014, 19:48
Re: [HELP]Re-making dialog - by darkokan - 06.10.2014, 06:12
Re: [HELP]Re-making dialog - by darkokan - 06.10.2014, 08:26
Re: [HELP]Re-making dialog - by dionisak0s - 06.10.2014, 16:59
Re: [HELP]Re-making dialog - by YanLanger - 06.10.2014, 17:09
Re: [HELP]Re-making dialog - by dionisak0s - 06.10.2014, 17:52
Re: [HELP]Re-making dialog - by darkokan - 06.10.2014, 17:59
Re: [HELP]Re-making dialog - by dionisak0s - 07.10.2014, 14:20

Forum Jump:


Users browsing this thread: 1 Guest(s)