ShowPlayerDialog problem.
#1

so i've got this code here.
pawn Код:
CMD:weapons(playerid,params[])
{
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You can not use this command while you are in a vehicle");
    else if(!IsPlayerInAnyVehicle(playerid))
    {
        new Weapons[256];
        strcat(Weapons,""#COL_WHITE"1):Silenced Pistol (100$)\n"#COL_WHITE"2): Deagle (200$)\n"#COL_YELLOW"3): Shotgun (500$)\n"#COL_YELLOW"4): Combat Shotgun (1000$)\n");
        strcat(Weapons,""#COL_YELLOW"5): Sawnoff-Shotgun (500$)\n"#COL_ORANGE"6):UZI (300$)\n");
        strcat(Weapons,""#COL_ORANGE"7): Tec9 (300$)\n"#COL_ORANGE"8): M4 (1000$)\n"#COL_ORANGE"9): MP5 (1000$)\n 10):Sniper (2000$)\n");
        strcat(Weapons,""#COL_RED""#COL_RED"11): Parachute (50$)\n");
        strcat(Weapons,""#COL_RED"12): Baseball Bat (500$)\n");
        strcat(Weapons,""#COL_RED"13): Chain Saw(10000$)\n");
        strcat(Weapons,""#COL_RED"14): Katana(500$)\n "#COL_RED"13): Pool Cue(500$)\n");
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Weapons:",Weapons,"OK", "Close");
    }
    return 1;
}
When i type /weapons
it doesn't show Sniper rifle weapon and all choices after it , why?
Also , when i press Close it still buys the weapon , what's needed to close the dialog on clicking close?
Reply
#2

Weapons[512]
Reply
#3

Have OnDialogResponse ?
Reply
#4

You should probably just use a normal string format. Like so...
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>


CMD:weapons(playerid,params[])
{
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFF0000AA,"You can not use this command while you are in a vehicle");
    else if(!IsPlayerInAnyVehicle(playerid))
    {
        new string[256],string2[256],string3[500];
        format(string,sizeof(string),"{FFFFFF}1):Silenced Pistol (100$)\n2): Deagle (200$)\n{FFFF00}3): Shotgun (500$)\n4): Combat Shotgun (1000$)\n5): Sawnoff-Shotgun (500$)\n{FF8C00}6):UZI (300$)\n");
        format(string2,sizeof(string2),"{FF8C00}7): Tec9 (300$)\n8): M4 (1000$)\n9): MP5 (1000$)\n 10):Sniper (2000$)\n{FF0000}11): Parachute (50$)\n12): Baseball Bat (500$)\n13): Chain Saw(10000$)\n14): Katana(500$)\n13): Pool Cue(500$)\n");
        format(string3,sizeof(string3),"%s%s",string,string2);
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Weapons:",string3,"OK", "Close");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 2)
    {
        if(response) //IF THEY PRESSED 'OK'. !response if they pressed 'Close'
        {
            switch(listitem)
            {
                case 0:
                {
                    if(GetPlayerMoney(playerid) < 100)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 23, 100);
                    GivePlayerMoney(playerid, -100);
                    return 1;
                }
                case 1:
                {
                    if(GetPlayerMoney(playerid) < 200)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 24, 100);
                    GivePlayerMoney(playerid, -200);
                    return 1;
                }
                case 2:
                {
                    if(GetPlayerMoney(playerid) < 500)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 25, 100);
                    GivePlayerMoney(playerid, -500);
                    return 1;
                }
                case 3:
                {
                    if(GetPlayerMoney(playerid) < 1000)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 27, 100);
                    GivePlayerMoney(playerid, -1000);
                    return 1;
                }
                case 4:
                {
                    if(GetPlayerMoney(playerid) < 500)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 26, 100);
                    GivePlayerMoney(playerid, -500);
                    return 1;
                }
                case 5:
                {
                    if(GetPlayerMoney(playerid) < 300)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 28, 100);
                    GivePlayerMoney(playerid, -300);
                    return 1;
                }
                case 6:
                {
                    if(GetPlayerMoney(playerid) < 300)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 32, 100);
                    GivePlayerMoney(playerid, -300);
                    return 1;
                }
                case 7:
                {
                    if(GetPlayerMoney(playerid) < 1000)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 31, 100);
                    GivePlayerMoney(playerid, -100);
                    return 1;
                }
                case 8:
                {
                    if(GetPlayerMoney(playerid) < 1000)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 29, 100);
                    GivePlayerMoney(playerid, -1000);
                    return 1;
                }
                case 9:
                {
                    if(GetPlayerMoney(playerid) < 2000)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 34, 100);
                    GivePlayerMoney(playerid, -2000);
                    return 1;
                }
                case 10:
                {
                    if(GetPlayerMoney(playerid) < 50)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 46, 1);
                    GivePlayerMoney(playerid, -50);
                    return 1;
                }
                case 11:
                {
                    if(GetPlayerMoney(playerid) < 500)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 5, 1);
                    GivePlayerMoney(playerid, -500);
                    return 1;
                }
                case 12:
                {
                    if(GetPlayerMoney(playerid) < 10000)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 9, 1);
                    GivePlayerMoney(playerid, -10000);
                    return 1;
                }
                case 13:
                {
                    if(GetPlayerMoney(playerid) < 500)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 8, 1);
                    GivePlayerMoney(playerid, -500);
                    return 1;
                }
                case 14:
                {
                    if(GetPlayerMoney(playerid) < 500)
                    return SendClientMessage(playerid, 0xFF0000AA, "You have insufficient funds to purchase this item.");
                    GivePlayerWeapon(playerid, 7, 1);
                    GivePlayerMoney(playerid, -500);
                    return 1;
                }
            }
        }
        else return SendClientMessage(playerid, 0xFF0000AA, "Selection Cancelled.");
        return 1;
    }
    return 1;
}
EDIT: OnDialogResponse has nothing to do with an item not appearing in the dialog.
Reply
#5

Increase string size
pawn Код:
new Weapons[500];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)