Having problems with dialogs..
#1

Hi, so I've recently started changing my boring commands that used many 'format' with dialogs. But now I'm experiencing some problems.
This script that I'm showing below, has a bug. I type the /buyitem command, then it sends me to dialog itemsmenu. Then I pick one item and it just starts spamming my chat with the "SendClientMessage(playerid, COLOR_WHITE, "You've bought a new hat! Use the cmd /use to put it on.");"
I have no idea why this is happening, maybe it's something I missed.

Thank you for your help.

pawn Код:
#define capsmenu 2734

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmd, "/buyitem", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            for(new i = 0; i < sizeof(Businesses); i++)
            {
                if (PlayerToPoint(25.0, playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ]))
                {
                    if(GetPlayerVirtualWorld(playerid) == i)
                    {
                        if(Businesses[i][BizType] == 6)
                        {
                            if(Businesses[i][Products] != 0)
                            {
                                   ShowPlayerDialog(playerid, itemsmenu, DIALOG_STYLE_LIST, "Items List", "Glasses \nHats \nBarets \nMasks \nWatches \nLasers \nGuitars \nHeadPhones \nOther", "Choose", "Cancel");
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_WHITE, "The shop ran out of stock...");
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "You need to be in a clothes shop.");
                        }
                    }
                }
            }
        }
        return 1;
    }
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == capsmenu)
    {
        if(response)
        {
            if(listitem == 0)
            {
                if(GetPlayerCash(playerid) >= 750)
                {
                    TogglePlayerControllable(playerid,1);
                    SendClientMessage(playerid, COLOR_WHITE, "You've bought a new hat! Use the cmd /use to put it on.");
                    PlayerInfo[playerid][pcap] = 1;
                    GivePlayerCash(playerid,-750);
                    Businesses[i][Products]--;
                    Businesses[i][Till]+=750;
                    SaveBusinesses();
                }
                else
                {
                    SendClientMessage(playerid, COLOR_WHITE, "You don't have enough money.");
                    TogglePlayerControllable(playerid,1);
                }
            }
            if(listitem == 1)
            {
                if(GetPlayerCash(playerid) >= 750)
                {
                    TogglePlayerControllable(playerid,1);
                    SendClientMessage(playerid, COLOR_WHITE, "You've bought a new hat! Use the cmd /use to put it on.");
                    PlayerInfo[playerid][pcap] = 2;
                    GivePlayerCash(playerid,-750);
                    Businesses[i][Products]--;
                    Businesses[i][Till]+=750;
                    SaveBusinesses();
                }
                else
                {
                    SendClientMessage(playerid, COLOR_WHITE,"You don't have enough money.");
                    TogglePlayerControllable(playerid,1);
                }
            }
        }
        if(!response)
        {
            ShowPlayerDialog(playerid, itemsmenu, DIALOG_STYLE_LIST, "Items List", "Glasses \nHats \nBarets \nMasks \nWatches \nLasers \nGuitars \nHeadPhones \nOther", "Choose", "Cancel");
        }
        return 1;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)