Item saving to DB problem

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
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
YukiLT
Posts: 47
Joined: Tue Mar 11, 2008 4:52 pm

Item saving to DB problem

Post 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?
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Item saving to DB problem

Post by JIV »

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

Re: Item saving to DB problem

Post 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?
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Item saving to DB problem

Post by JIV »

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

Re: Item saving to DB problem

Post 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?
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Item saving to DB problem

Post by JIV »

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

Re: Item saving to DB problem

Post by YukiLT »

Thank you very much, will test it : )
YukiLT
Posts: 47
Joined: Tue Mar 11, 2008 4:52 pm

Re: Item saving to DB problem

Post by YukiLT »

Items still dissapear.. heh.. Any other ideas?
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Item saving to DB problem

Post by JIV »

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

Re: Item saving to DB problem

Post by YukiLT »

Still dissapears.. I guess it is.. : ) No idea where though.
Post Reply