So for some reason, the item selected is always listitem = 0; No matter what item it is at the time of selection, it'll always set to 0 with the odd chance it uses the correct one... Once out of like ~50 tries. I'm being blind or overlooking something, because this is giving me a real headache.
Stock to show inventory items;
That works fine, shows all the correct items in a users inventory etc etc.
The DIALOG_INVENTORY_SELECT;
Stock to show inventory items;
PHP Code:
stock ShowCharacterInventory(playerid)
{
new larstr[600], titlestr[80], counter = 0;
new newinv = ReturnInvItems(playerid);
printf("%i", newinv);
for(new i = 0; i < newinv; i++)
{
Dialog_SetListitemPreviewRot(playerid, i, -30.0, 0.0, 25.0, 1.0, 0xFFFFFFFF, 0xFFFFFFFF);
format(larstr, sizeof(larstr), "%s%i\t%s (%i)\n", larstr, InvItems[i][iModelID], InvItems[i][iItemName], InvItems[i][iItemAmount]);
counter++;
}
if(counter == 0)
return SendClientMessage(playerid, COLOR_RED, "SERVER: You have no inventory items");
format(titlestr, sizeof(titlestr), "Inventory: %i/%i", counter, 16);
ShowPlayerDialog(playerid, DIALOG_INVENTORY_SELECT, DIALOG_STYLE_PREVIEW_MODEL, titlestr, larstr, "Select", "<<");
return 1;
}
The DIALOG_INVENTORY_SELECT;
PHP Code:
case DIALOG_INVENTORY_SELECT:
{
if(!response)
return 0;
new str[128];
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new world = GetPlayerVirtualWorld(playerid);
new int = GetPlayerInterior(playerid);
ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
printf("%i - %i", listitem, InvItems[listitem][iItemsID]);
DropItem(playerid, InvItems[listitem][iItemsID], InvItems[listitem][iModelID], InvItems[listitem][iItemAmount], InvItems[listitem][iItemName], x, y, z, world, int);
RemoveFromInv(playerid, InvItems[listitem][iItemsID], InvItems[listitem][iModelID], InvItems[listitem][iItemName], InvItems[listitem][iItemAmount]);
format(str, sizeof(str), "You have dropped a %s.", InvItems[listitem][iItemName]);
SendClientMessage(playerid, COLOR_WHITE, str);
}