L2JMobius

C6 Inventory double items in auto pick up

cardinal · 14 · 924

Offline cardinal

  • Vassal
  • *
    • Posts: 2
I have problem, when i kill a mob and have my Inventory opened i see the item i pick up double. If i close it and reopen it its normal.


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 333

Offline jamiskater

  • Vassal
  • *
    • Posts: 4
Same here, with autoloot. Anything new in inventory will double. Reopening the inventory refreshes it.
If I have a quest and get a QI, then the inventory refreshes.
Just a quality of life issue, since I like to play with my inventory opened :D


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 333
Find the doPickupItem function inside Player and try to send an itemlist or inventoryUpdate packet after each pickup.


Offline nasseka

  • Distinguished King
  • *****
    • Posts: 1729
    • L2Unknown
thought of the itemlist but usually it's a bit hvy on that party. Inventory update packet would be the best but did it exist in c6? xD


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 333
It does  ;D

Code: [Select]
final InventoryUpdate iu = new InventoryUpdate();
iu.addItem(item);
player.sendPacket(iu);


Offline jamiskater

  • Vassal
  • *
    • Posts: 4
Tried this, doesn't work, still duplicates new items in inventory until I re-open it:

(I'm not a coder, just copy-paster trying my luck ;D )
Code: [Select]
/**
* Manage AutoLoot Task.<br>
* <br>
* <b><u>Actions</u>:</b><br>
* <li>Send a System Message to the Player : YOU_PICKED_UP_S1_ADENA or YOU_PICKED_UP_S1_S2</li>
* <li>Add the Item to the Player inventory</li>
* <li>Send a Server->Client packet InventoryUpdate to this Player with NewItem (use a new slot) or ModifiedItem (increase amount)</li>
* <li>Send a Server->Client packet StatusUpdate to this Player with current weight</li><br>
* <font color=#FF0000><b><u>Caution</u>: If a Party is in progress, distribute Items between party members</b></font>
* @param target The Item dropped
* @param item the item
*/
public void doAutoLoot(Attackable target, ItemHolder item)
{
if (isInParty())
{
getParty().distributeItem(this, item, false, target);
// Send inventory update packet
final InventoryUpdate playerIU = new InventoryUpdate();
sendPacket(playerIU);

}
else if (item.getId() == 57)
{
addAdena("AutoLoot", item.getCount(), target, true);
// Send inventory update packet
final InventoryUpdate playerIU = new InventoryUpdate();
sendPacket(playerIU);

}
else
{
addItem("AutoLoot", item.getId(), item.getCount(), target, true);
// Send inventory update packet
final InventoryUpdate playerIU = new InventoryUpdate();
sendPacket(playerIU);

}
}


The original code is only this (lines 4851+):
Code: [Select]
/**
* Manage AutoLoot Task.<br>
* <br>
* <b><u>Actions</u>:</b><br>
* <li>Send a System Message to the Player : YOU_PICKED_UP_S1_ADENA or YOU_PICKED_UP_S1_S2</li>
* <li>Add the Item to the Player inventory</li>
* <li>Send a Server->Client packet InventoryUpdate to this Player with NewItem (use a new slot) or ModifiedItem (increase amount)</li>
* <li>Send a Server->Client packet StatusUpdate to this Player with current weight</li><br>
* <font color=#FF0000><b><u>Caution</u>: If a Party is in progress, distribute Items between party members</b></font>
* @param target The Item dropped
* @param item the item
*/
public void doAutoLoot(Attackable target, ItemHolder item)
{
if (isInParty())
{
getParty().distributeItem(this, item, false, target);
}
else if (item.getId() == 57)
{
addAdena("AutoLoot", item.getCount(), target, true);
}
else
{
addItem("AutoLoot", item.getId(), item.getCount(), target, true);
}
}
}


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 333
Try this:

Code: [Select]
final Item item = addItem("AutoLoot", item.getId(), item.getCount(), target, true);
// Send inventory update packet
final InventoryUpdate playerIU = new InventoryUpdate();
iu.addItem(item);
sendPacket(playerIU);


Online dramaa

  • Elder
  • ****
    • Posts: 120
tbh i have this problem too, i am just too afraid to ask, cus i have new questions every day and people are tired of me i am sure xd same happening on cp or when opening any box, gives everything with duplicate, but in my case when i close and open  bag, not disappearing :/


Online dramaa

  • Elder
  • ****
    • Posts: 120
Try this:

Code: [Select]
final Item item = addItem("AutoLoot", item.getId(), item.getCount(), target, true);
// Send inventory update packet
final InventoryUpdate playerIU = new InventoryUpdate();
iu.addItem(item);
sendPacket(playerIU);

does it work? and where it goes, please tell me if not a problem


Offline ektorasdj

  • Vassal
  • *
    • Posts: 6
Hello, i am also experiencing the same problem in my interlude server. I will try your suggestion after i get off work today and get back to you.
Thank you


Offline ektorasdj

  • Vassal
  • *
    • Posts: 6
Hello !
@G-hamsteR I am not a coder (please bare with me) ,

I get some errors on eclipse:



Thank you for your help


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 333
Hello !
@G-hamsteR I am not a coder (please bare with me) ,

I get some errors on eclipse:



Thank you for your help

Change to the following:

Code: [Select]
final Item itemG = addItem("AutoLoot", item.getId(), item.getCount(), target, true);
final InventoryUpdate playerIU = new InventoryUpdate();
playerIU.addItem(itemG);
sendPacket(playerIU);


Offline ektorasdj

  • Vassal
  • *
    • Posts: 6
Hello!
Thank you for your prompt reply,
Still getting a small error: