Case/Dialog identification issue -
cuzido - 07.02.2016
Hi. I'm working on a dynamic dialog inventory system with a friend and we got stuck with something I'm not being able to solve.
When you type /inventory, you're supposed to get a list with the current items you're holding. It changes depending on the items. That's working fine.
However, if I have:
1. Cocaine
2. Hiking Bag
3. Marijuana
Number 1 and 2 work fine upon selection, but if I select item number 3, I'll get the option menu for Item 2, Hiking Bag.
I know what's wrong and why that's happening, but I have been breaking my back this weekend trying to go around it, but I haven't found a solution. Could anyone give me a hand with this?
http://pastebin.com/CXqwH58j
The problem starts at Line 74. I'm sure there is a better way to do what I'm trying to, but I wouldn't be posting here if I knew how to do it
Thanks for the attention and any help.
Re: Case/Dialog identification issue -
cuzido - 08.02.2016
Bump! Any ideas, please?
Re: Case/Dialog identification issue -
Vince - 08.02.2016
Horrible indentation. I also have no idea what those while loops are doing there.

I mean, what is this even?
PHP код:
if(PlayerInfo[playerid][pIHikingBag] >= 1)
{
while(PlayerInfo[playerid][pIAmphetamine] >= 1 || PlayerInfo[playerid][pIBackpack] >= 1 || PlayerInfo[playerid][pICocaine] >= 1)
{
while(PlayerInfo[playerid][pIBackpack] >= 1 || PlayerInfo[playerid][pICocaine] >= 1)
{
return ShowPlayerDialog(playerid, DIALOG_IHIKING, DIALOG_STYLE_LIST,""COL_WHITE"Hiking Bag", "Use\nShow\nDrop", "Select", "Cancel"); // This is where my problem is, I know it's returning the Backpack twice, so it figures Hiking Bag is where it should be. I can't figure out how to go through this.
}
}
}
A while loop within a while loop and both do jack shit.
Re: Case/Dialog identification issue -
cuzido - 08.02.2016
It's meant to check if the player has items on slot 1 or 2, in order for the "hiking bag menu" to show up at slot 3 of the item list.
It's working fine on case 0 and case 1, but when I get to case 2 it double checks "pIBackpack" because of the while loop (gives me the same result as case 1) and I know that's wrong. And that's where we can't figure out how to make it work.
We're looking at nxor trying to find out if that could be of any help but no success yet.
Re: Case/Dialog identification issue -
Nero_3D - 08.02.2016
Create an inventory array and than you could access the specific item without problems
This code only works if the order of the items is the same as in your inventory dialog
PHP код:
ShowItemDialog(playerid, item) {
const
size = 5
;
if(0 <= item < size) {
new
count,
inventory[size]
;
if(PlayerInfo[playerid][pIAmphetamine] >= 1) inventory[count++] = 1;
if(PlayerInfo[playerid][pIBackpack] >= 1) inventory[count++] = 2;
if(PlayerInfo[playerid][pICocaine] >= 1) inventory[count++] = 3;
if(PlayerInfo[playerid][pIHikingBag] >= 1) inventory[count++] = 4;
if(PlayerInfo[playerid][pIMarijuana] >= 1) inventory[count++] = 5;
static
info[] = "Use\nShow\nDrop",
button1[] = "Select",
button2[] = "Cancel"
;
switch(inventory[item]) {
case 1: return ShowPlayerDialog(playerid, DIALOG_IAMPHETAMINE, DIALOG_STYLE_LIST, COL_WHITE "Amphetamine Pill", info, button1, button2);
case 2: return ShowPlayerDialog(playerid, DIALOG_IBACKPACK, DIALOG_STYLE_LIST, COL_WHITE "Backpack", info, button1, button2);
case 3: return ShowPlayerDialog(playerid, DIALOG_ICOCAINE, DIALOG_STYLE_LIST, COL_WHITE "Ball of Cocaine", info, button1, button2);
case 4: return ShowPlayerDialog(playerid, DIALOG_IHIKING, DIALOG_STYLE_LIST, COL_WHITE "Hiking Bag", info, button1, button2);
case 5: return ShowPlayerDialog(playerid, DIALOG_IMARIJUANA, DIALOG_STYLE_LIST, COL_WHITE "Marijuana Cigarette", info, button1, button2);
}
}
return false;
}
PHP код:
case DIALOG_INVENTORY:
{
if(response)
{
ShowItemDialog(playerid, listitem);
}
}
Re: Case/Dialog identification issue -
cuzido - 08.02.2016
It works! And it seems so easy haha
Thank you both for the attention and Nero for the code!