First of all, why a public function ? Will it be called by CallLocal / RemoteFunction or even a timer at all ? If not, it is not needed.
You will need to loop once again and for each item you find the player is owner, you need to increase a variable.When it is then equal to the listitem, that is the index for the array.
PHP код:
ShowPlayerItems(playerid)
{
new info[512];
foreach(new i : i_count)
{
if (Item[i][item_owner] == DataPlayer[playerid][player_uid])
{
format(info, sizeof(info), "%s\n[%d]\t%s (%d | %d)", info, Item[i][item_uid], Item[i][item_name], Item[i][item_amount], Item[i][item_amount2]);
}
}
// no need of strlen, if first character is NULL then it is empty.
if (!info[0]) ShowPlayerDialog(playerid, DIALOG_I, DIALOG_STYLE_MSGBOX, "Przedmioty | Informacja", "Przykro nam ale twoja postać nie posiada przedmiotуw", "Ok", "");
else ShowPlayerDialog(playerid, DIALOG_P, DIALOG_STYLE_LIST, "Przedmioty", info, "Usage", "Close");
return 1;
}
case DIALOG_P:
{
if (!response) return 1;
new itemid = -1;
foreach(new i : i_count)
{
if (Item[i][item_owner] == DataPlayer[playerid][player_uid])
{
if (++itemid == listitem)
{
printf("%d ITEMID USE\n", itemid);
UsePlayerItem(playerid, Item[itemid][item_type], Item[itemid][item_uid]);
//ShowPlayerDialog(playerid, DIALOG_P_O, DIALOG_STYLE_LIST, "Item | Options", "Use Item\nInfo\n", "Wybierz", "Anuluj");
break; // stops the loop
}
}
}
return 1;
}
@Mencent: If you loop until the size of Item array, what you would be looking for is the "item_uid" from the "inputtext". In order to do that, you'd have to use strmid and strfind for the position of "[" and "]".
It's better to loop through iterator "i_count" because it will have less items.