Help Items system
#1

Hello.

I need your help.

Код:
forward ShowPlayerItems(playerid);
public ShowPlayerItems(playerid)
{
  new info[512], result;
  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]);
      result++;
    }
  }
  if(!strlen(info))
  {
    ShowPlayerDialog(playerid, DIALOG_I, DIALOG_STYLE_MSGBOX, "Przedmioty | Informacja", "Przykro nam ale twoja postać nie posiada przedmiotуw", "Ok", "");
  }
  ShowPlayerDialog(playerid, DIALOG_P, DIALOG_STYLE_LIST, "Przedmioty", info, "Usage", "Close");
  return 1;
}
how can I learn from the id of this object?

Код:
      new item_sscanf_uid, item_sscanf_info[128], itemid;
      if(sscanf(inputtext, "ds[128]", item_sscanf_uid, item_sscanf_info))
      {
          printf("%d ITEMID USE\n", item_sscanf_uid);
          return 1;
      }
      itemid = item_sscanf_uid;
      printf("%d ITEMID USE\n", itemid);
      UsePlayerItem(playerid, Item[itemid][item_type], Item[itemid][item_uid]);
in this way it does not work
Reply
#2

Any help?
Reply
#3

Hello.

Sorry, but I don't understand what exactly do you want. Can you try to explain your problem?
Reply
#4

I use Commands / p shows me up a list of items when a player chooses an object by means of a button , use the switch uses to accept I can not download the object id

Edit

Код:
case DIALOG_P:
    {
      if(!response) return 1;

      new item_sscanf_uid, item_sscanf_info[128], itemid;
      if(sscanf(inputtext, "ds[128]", item_sscanf_uid, item_sscanf_info))
      {
          printf("%d ITEMID USE\n", item_sscanf_uid);
          return 1;
      }
      itemid = item_sscanf_uid;
      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");
      return 1;
    }
I can not retrieve the object id that the player chosen in the list and I have no idea how to do it - does not work
Reply
#5

Any ideas how get select listitem id in dialogid?
Reply
#6

I think this is the right what you want.
PHP код:
case DIALOG_P:
{
    if(!
response)return 1;
    new 
count;
    for(new 
i;i<sizeof(Item);i++)
    {
        if(
listitem == count)
        {
            
//Item[i][item_type] is the "Item-Type" which is clicked in the dialog.
            
UsePlayerItem(playeridItem[i][item_type], Item[i][item_uid]);
            break;
        }
        
count ++;
    }

Reply
#7

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.
Reply
#8

When a player chooses test or other object , because I want to press the button use the get GameID in dialog_p

http://imgur.com/a/kESP3
Reply
#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
#10

How do I get GameID item when the player presses the button use .

because now there is a problem when the item have GameID 12 and is in position one and uses the item id 12 and uses item one
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)