Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use
viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
YukiLT
Posts: 47 Joined: Tue Mar 11, 2008 4:52 pm
Post
by YukiLT » Sun Jun 13, 2010 8:26 am
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?
JIV
L2j Veteran
Posts: 1882 Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:
Post
by JIV » Sun Jun 13, 2010 8:42 am
try use direct insert to inventory - some method from com.l2jserver.gameserver.model.itemcontainer.PcInventory
YukiLT
Posts: 47 Joined: Tue Mar 11, 2008 4:52 pm
Post
by YukiLT » Sun Jun 13, 2010 8:55 am
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?
JIV
L2j Veteran
Posts: 1882 Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:
Post
by JIV » Sun Jun 13, 2010 9:01 am
no, another one - com.l2jserver.gameserver.model.itemcontainer.PcInventory.addItem(String, int, long, L2PcInstance, L2Object)
YukiLT
Posts: 47 Joined: Tue Mar 11, 2008 4:52 pm
Post
by YukiLT » Sun Jun 13, 2010 9:33 am
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?
JIV
L2j Veteran
Posts: 1882 Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:
Post
by JIV » Sun Jun 13, 2010 9:48 am
eh not like that, put there
Code: Select all
_inventory.addItem("Loot", 4358, 1, this, null);
YukiLT
Posts: 47 Joined: Tue Mar 11, 2008 4:52 pm
Post
by YukiLT » Sun Jun 13, 2010 10:01 am
Thank you very much, will test it : )
YukiLT
Posts: 47 Joined: Tue Mar 11, 2008 4:52 pm
Post
by YukiLT » Sun Jun 13, 2010 10:19 am
Items still dissapear.. heh.. Any other ideas?
JIV
L2j Veteran
Posts: 1882 Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:
Post
by JIV » Sun Jun 13, 2010 10:45 am
Code: Select all
_inventory.addItem("Loot", 4358, 1, this, null).updateDatabase(true);
if this will not work then problem is something else.
YukiLT
Posts: 47 Joined: Tue Mar 11, 2008 4:52 pm
Post
by YukiLT » Sun Jun 13, 2010 11:09 am
Still dissapears.. I guess it is.. : ) No idea where though.