Help Items system
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
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_count)
    {
        if (
Item[i][item_owner] == DataPlayer[playerid][player_uid])
        {
            
format(infosizeof(info), "%s\n[%d]\t%s (%d | %d)"infoItem[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(playeridDIALOG_IDIALOG_STYLE_MSGBOX"Przedmioty | Informacja""Przykro nam ale twoja postać nie posiada przedmiotуw""Ok""");
    else 
ShowPlayerDialog(playeridDIALOG_PDIALOG_STYLE_LIST"Przedmioty"info"Usage""Close");
    return 
1;
}
case 
DIALOG_P:
{
    if (!
response) return 1;
    new 
itemid = -1;
    foreach(new 
i_count)
    {
        if (
Item[i][item_owner] == DataPlayer[playerid][player_uid])
        {
            if (++
itemid == listitem)
            {
                
printf("%d ITEMID USE\n"itemid);
                
UsePlayerItem(playeridItem[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.
THANKS MAN! REP+
Reply


Messages In This Thread
Help Items system - by Himan - 08.08.2016, 13:32
Re: Help Items system - by Himan - 08.08.2016, 13:58
Re: Help Items system - by Mencent - 08.08.2016, 14:20
Re: Help Items system - by Himan - 08.08.2016, 14:25
Re: Help Items system - by Himan - 08.08.2016, 16:31
Re: Help Items system - by Mencent - 08.08.2016, 16:41
Re: Help Items system - by Konstantinos - 08.08.2016, 16:46
Re: Help Items system - by Himan - 08.08.2016, 16:54
Re: Help Items system - by Himan - 08.08.2016, 17:00
Re: Help Items system - by Himan - 08.08.2016, 17:30

Forum Jump:


Users browsing this thread: 2 Guest(s)