SA-MP Forums Archive
OnDialogResponse logic for dynamic systems - 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: OnDialogResponse logic for dynamic systems (/showthread.php?tid=581245)



OnDialogResponse logic for dynamic systems - 2KY - 11.07.2015

I have the following business/item system at the moment:

pawn Код:
enum E_BUSINESSES
{
    ID,
    Type,
    Name[64],
   
    Int,
    VW,
    Float: IntX,
    Float: IntY,
    Float: IntZ,
    Float: IntA,
   
    ExitInt,
    ExitVW,
    Float: ExitX,
    Float: ExitY,
    Float: ExitZ,
    Float: ExitA
};

enum E_ITEMS
{
    ID,
    Type,
    Name[64]
};

new
    BusinessInfo[MAX_BUSINESSES][E_BUSINESSES],
    ItemInfo[MAX_ITEMS][E_ITEMS];
pawn Код:
CMD:shop(playerid, params[])
{
    if(PlayerInfo[playerid][IsInBusiness] != 0)
    {
        new
            biztype = BusinessInfo[PlayerInfo[playerid][IsInBusiness]][Type],
            str[128],
            str2[256];

        for(new i; i < MAX_ITEMS; i++)
        {
            if(ItemInfo[i][Type] == biztype)
            {
                format(str, sizeof(str), "%s\n", ItemInfo[i][Name]);
                strcat(str2, str);
            }
        }
        ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_LIST, "Shop", str2, "Buy", "Close");
    }
    return 1;
}
My problem is finding the logic behind the dialog response, how am I going to figure out what 'listitem' the player selects when the list is populated dynamically? If you have any ideas, post them down below because I'm clueless at the moment as to how it's going to work, or could work.