11.07.2015, 18:56
I have the following business/item system at the moment:
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.
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;
}