Dialog messup
#1

Hey there again hehe.
Im creating my server and now comes the time when i want to add inventory system in it. Im using THIS system for that.
There is that command who checks player inventory -
pawn Код:
if(!strcmp(cmdtext[1],"myitems",true))
{
  new idx,amount,itemname[MAX_ITEM_NAME];
  new tmp[128];
  while(GetPlayerItemInfo(playerid,idx,itemname,_,amount))
  {
    if(strlen(itemname))
    {
      format(tmp,128,"%s -- %d",itemname,amount);
      SendClientMessage(playerid,0xFFFFFFFF,tmp);
    }
  }
  return 1;
}
and outcome is this -

But i want to remaki it to dialog_style_msgbox
Code:
pawn Код:
if(!strcmp(cmdtext[1],"myitems",true))
    {
      new idx, amount,itemname[MAX_ITEM_NAME];
      new tmp[128];
      while(GetPlayerItemInfo(playerid,idx,itemname,_,amount))
      {
        if(strlen(itemname))
        {
          format(tmp,128,"%s -- %d",itemname,amount);
          ShowPlayerDialog(playerid, INVENTORY, DIALOG_STYLE_MSGBOX, "{6199D4}Inventars.", tmp,"Aizvert", "");
        }
      }
      return 1;
    }
and outcome is this
Items is saving in file in that order
Код:
Medkit4Armour3Mask3
anyone can help me to get it to dialog?
Thanks
Reply
#2

And how can we help you?
You did that to dialog,do it like this for all and be sure you use differit id for all dialogs.
And for this
Код:
Medkit4Armour3Mask3
you need to add \n for new line.
Reply
#3

Saving is not a problem. Just outcome of the command, when im using sendclientmessage it shows all items when dialog only last piece i want that in dialog there are all items not only last. hope u get a point.
Reply
#4

Any help guys?
Reply
#5

Код:
if(!strcmp(cmdtext[1],"myitems",true))
{
    new idx, amount,itemname[MAX_ITEM_NAME];
    new tmp[128], string[256];
    while(GetPlayerItemInfo(playerid,idx,itemname,_,amount))
    {
        if(strlen(itemname))
        {
          format(tmp,128,"%s -- %d\n",itemname,amount);
	  strcat(string, tmp);
        }
    }
    ShowPlayerDialog(playerid, INVENTORY, DIALOG_STYLE_MSGBOX, "{6199D4}Inventars.", tmp,"Aizvert", "");
    return 1;
}
try this here. might work. (I don't really like strcat so better try it lol)

EDIT: For you to understand, strcat moves 1 string into another. You first have to make a string with all Information before you can display the dialog. So first you collect the information in the while(GetPlayerItemInfo loop and then you display the dialog after it.
Reply
#6

Still showing only last item. first 2 doesnt show
Reply
#7

Change the format line to this:

pawn Код:
format(tmp,128,"%s%s -- %d\n",tmp,itemname,amount);
I recommend changing the length of the 'tmp' variable to 200, because the person might have more items.
Reply
#8

Thank u. Working.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)