SA-MP Forums Archive
Dialog Response - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dialog Response (/showthread.php?tid=365428)



Dialog Response - Mento - 02.08.2012

Hello, I am wondering why this is not working:
pawn Код:
if(dialogid == DIALOGID_BS)
    {
        for(new i = 0; i<MAX_BUSINESSES;i++)
        {
            if(response)
            {
                if(IsPlayerInRangeOfPoint(playerid,25,BusinessInfo[i][bEntranceX],BusinessInfo[i][bEntranceY],BusinessInfo[i][bEntranceZ]))
                {
                    new amount = strval(inputtext);
                    if(amount > 0 && amount < 15000)
                    {
                        BusinessInfo[i][bFee][0] = amount;
                        GameTextForPlayer(playerid,"~g~Price has been changed",3000,4);
                        break;
                    }
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOGID_BUSINESSPRICES, DIALOG_STYLE_LIST, "Business Menu", BItems(i), "Edit", "Back");
            }
        }
    }
    if(dialogid == DIALOGID_BS1)
    {
        for(new i = 0; i<MAX_BUSINESSES;i++)
        {
            if(response)
            {
                if(IsPlayerInRangeOfPoint(playerid,25,BusinessInfo[i][bEntranceX],BusinessInfo[i][bEntranceY],BusinessInfo[i][bEntranceZ]))
                {
                    new amount = strval(inputtext);
                    if(amount > 0 && amount < 15000)
                    {
                        BusinessInfo[i][bFee][1] = amount;
                        GameTextForPlayer(playerid,"~g~Price has been changed",3000,4);
                        break;
                    }
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOGID_BUSINESSPRICES, DIALOG_STYLE_LIST, "Business Menu", BItems(i), "Edit", "Back");
            }
        }
    }
    if(dialogid == DIALOGID_BS2)
    {
        for(new i = 0; i<MAX_BUSINESSES;i++)
        {
            if(response)
            {
                if(IsPlayerInRangeOfPoint(playerid,25,BusinessInfo[i][bEntranceX],BusinessInfo[i][bEntranceY],BusinessInfo[i][bEntranceZ]))
                {
                    new amount = strval(inputtext);
                    if(amount > 0 && amount < 15000)
                    {
                        BusinessInfo[i][bFee][2] = amount;
                        GameTextForPlayer(playerid,"~g~Price has been changed",3000,4);
                        break;
                    }
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOGID_BUSINESSPRICES, DIALOG_STYLE_LIST, "Business Menu", BItems(i), "Edit", "Back");
            }
        }
    }
When the player goes and that dialog comes up and they respond, the variable doesn't get set...


Re: Dialog Response - Viiih - 02.08.2012

ShowPlayerDialog(playerid, DIALOGID_BUSINESSPRICES, DIALOG_STYLE_LIST, "Business Menu", BItems(i), "Edit", "Back");

DIALOGID_BUSINESSPRICES. Looks like you're messing up with the dialog ID's. The only "id's" I can notice on your code are: DIALOGID_BS, DIALOGID_BS1, DIALOGID_BS2. Check this up. I hope this works.


Re: Dialog Response - Mento - 03.08.2012

That is another dialog that it shows if they don't respond to the current dialog, so it's not that.


Re: Dialog Response - Knappen - 03.08.2012

pawn Код:
if(dialogid == DIALOGID_BS)
    {
        for(new i = 0; i<MAX_BUSINESSES;i++)
        {
            if(response)
            {
                if(IsPlayerInRangeOfPoint(playerid,25,BusinessInfo[i][bEntranceX],BusinessInfo[i][bEntranceY],BusinessInfo[i][bEntranceZ]))
                {
                    new amount = strval(inputtext);
                    if(amount > 0 && amount < 15000)
                    {
                        BusinessInfo[i][bFee][0] = amount;
                        GameTextForPlayer(playerid,"~g~Price has been changed",3000,4);
                        break;
                    }
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOGID_BUSINESSPRICES, DIALOG_STYLE_LIST, "Business Menu", BItems(i), "Edit", "Back");
            }
        }
        return 1;
    }
    if(dialogid == DIALOGID_BS1)
    {
        for(new i = 0; i<MAX_BUSINESSES;i++)
        {
            if(response)
            {
                if(IsPlayerInRangeOfPoint(playerid,25,BusinessInfo[i][bEntranceX],BusinessInfo[i][bEntranceY],BusinessInfo[i][bEntranceZ]))
                {
                    new amount = strval(inputtext);
                    if(amount > 0 && amount < 15000)
                    {
                        BusinessInfo[i][bFee][1] = amount;
                        GameTextForPlayer(playerid,"~g~Price has been changed",3000,4);
                        break;
                    }
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOGID_BUSINESSPRICES, DIALOG_STYLE_LIST, "Business Menu", BItems(i), "Edit", "Back");
            }
        }
        return 1;
    }
    if(dialogid == DIALOGID_BS2)
    {
        for(new i = 0; i<MAX_BUSINESSES;i++)
        {
            if(response)
            {
                if(IsPlayerInRangeOfPoint(playerid,25,BusinessInfo[i][bEntranceX],BusinessInfo[i][bEntranceY],BusinessInfo[i][bEntranceZ]))
                {
                    new amount = strval(inputtext);
                    if(amount > 0 && amount < 15000)
                    {
                        BusinessInfo[i][bFee][2] = amount;
                        GameTextForPlayer(playerid,"~g~Price has been changed",3000,4);
                        break;
                    }
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOGID_BUSINESSPRICES, DIALOG_STYLE_LIST, "Business Menu", BItems(i), "Edit", "Back");
            }
        }
        return 1;
    }
    return 0;
You have to return 1; after you've handled every dialog, and then return 0; at the end. That could be the problem, though I don't know.


Re: Dialog Response - Mento - 04.08.2012

I doubt that's the problem, but won't hurt to try it.

Yep it isn't that either, I am really not sure why it isn't setting the variable, anyone know?


Re: Dialog Response - tiernantheman - 04.08.2012

Make sure that's under OnDialogResponse.


Re: Dialog Response - Mento - 06.08.2012

Bump, anyone have a idea what is wrong with the dialog?


Re: Dialog Response - ReneG - 06.08.2012

The problem is obviously because this code isn't being ran.
pawn Код:
if(amount > 0 && amount < 15000)
{
    BusinessInfo[i][bFee][0] = amount;
    GameTextForPlayer(playerid,"~g~Price has been changed",3000,4);
    break;
}
Also, it doesn't make sense to loop through everything, and then check if response is true.
pawn Код:
if(response)
{
    for(new i = 0; i<MAX_BUSINESSES;i++) {
        if(IsPlayerInRangeOfPoint(playerid,25,BusinessInfo[i][bEntranceX],BusinessInfo[i][bEntranceY],BusinessInfo[i][bEntranceZ]))
        {
            new amount = strval(inputtext);
            if(amount > 0 && amount < 15000)
            {
                BusinessInfo[i][bFee][0] = amount;
                GameTextForPlayer(playerid,"~g~Price has been changed",3000,4);
                break;
            }
        }
    }
}
else
{
    ShowPlayerDialog(playerid, DIALOGID_BUSINESSPRICES, DIALOG_STYLE_LIST, "Business Menu", BItems(i), "Edit", "Back");
}
There could be a lot of things wrong, and you can easily fix this if you learn to debug. Perhaps the businesses' locations aren't even being loaded.


Re: Dialog Response - Mento - 06.08.2012

What? The business locations are being loaded as you can enter and exit fine. I looped through before checking the response because I needed it for the else statement, but you're right i'll remove that, but other then that it still isn't working, anyone else?