08.02.2016, 16:19
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
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);
}
}