Page 1 of 1
Item saving to DB problem
Posted: Sun Jun 13, 2010 8:26 am
by YukiLT
Hello Guys,
We have a small script included into the core, which adds an item after a player gains a PvP point.
The problem is that the item doesn't save to DB, so if you ever do a restart or exit the game, it dissapears from your inventory.
Code: Select all
public void increasePvpKills(L2Character target) { if (target instanceof L2PcInstance && AntiFeedManager.getInstance().check(this, target)) { // Add karma to attacker and increase its PK counter setPvpKills(getPvpKills() + 1);[b] addItem("Loot", 4358, 1, this, true); sendMessage("+1");[/b] // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter sendPacket(new UserInfo(this)); sendPacket(new ExBrExtraUserInfo(this)); } }
Anyone could help? What can I change so it instantly saves to DB?
Re: Item saving to DB problem
Posted: Sun Jun 13, 2010 8:42 am
by JIV
try use direct insert to inventory - some method from com.l2jserver.gameserver.model.itemcontainer.PcInventory
Re: Item saving to DB problem
Posted: Sun Jun 13, 2010 8:55 am
by YukiLT
JIV wrote:try use direct insert to inventory - some method from com.l2jserver.gameserver.model.itemcontainer.PcInventory
Which one is it? I can't locate it : >..
Code: Select all
public L2ItemInstance addItem(String process, int itemId, long count, L2PcInstance actor, L2Object reference) { L2ItemInstance item = super.addItem(process, itemId, count, actor, reference); if (item != null && item.getItemId() == ADENA_ID && !item.equals(_adena)) _adena = item; if (item != null && item.getItemId() == ANCIENT_ADENA_ID && !item.equals(_ancientAdena)) _ancientAdena = item; if (item != null && actor != null) { // Send inventory update packet if (!Config.FORCE_INVENTORY_UPDATE) { InventoryUpdate playerIU = new InventoryUpdate(); playerIU.addItem(item); actor.sendPacket(playerIU); } else actor.sendPacket(new ItemList(actor, false)); // Update current load as well StatusUpdate su = new StatusUpdate(actor.getObjectId()); su.addAttribute(StatusUpdate.CUR_LOAD, actor.getCurrentLoad()); actor.sendPacket(su); } return item; }
This one? And if so, how can I link this script to a specific item?
Re: Item saving to DB problem
Posted: Sun Jun 13, 2010 9:01 am
by JIV
no, another one - com.l2jserver.gameserver.model.itemcontainer.PcInventory.addItem(String, int, long, L2PcInstance, L2Object)
Re: Item saving to DB problem
Posted: Sun Jun 13, 2010 9:33 am
by YukiLT
Code: Select all
public void increasePvpKills(L2Character target) { if (target instanceof L2PcInstance && AntiFeedManager.getInstance().check(this, target)) { // Add karma to attacker and increase its PK counter setPvpKills(getPvpKills() + 1); com.l2jserver.gameserver.model.itemcontainer.PcInventory.addItem("Loot", 4358, 1, L2PcInstance, L2Object); sendMessage("+1");
What do I need to use in place of L2PcInstance and L2Object with this string?
Re: Item saving to DB problem
Posted: Sun Jun 13, 2010 9:48 am
by JIV
eh not like that, put there
Code: Select all
_inventory.addItem("Loot", 4358, 1, this, null);
Re: Item saving to DB problem
Posted: Sun Jun 13, 2010 10:01 am
by YukiLT
Thank you very much, will test it : )
Re: Item saving to DB problem
Posted: Sun Jun 13, 2010 10:19 am
by YukiLT
Items still dissapear.. heh.. Any other ideas?
Re: Item saving to DB problem
Posted: Sun Jun 13, 2010 10:45 am
by JIV
Code: Select all
_inventory.addItem("Loot", 4358, 1, this, null).updateDatabase(true);
if this will not work then problem is something else.
Re: Item saving to DB problem
Posted: Sun Jun 13, 2010 11:09 am
by YukiLT
Still dissapears.. I guess it is.. : ) No idea where though.