Jump to content
  • 0

[Request]Java Code


Question

5 answers to this question

Recommended Posts

  • 0
Posted

try adding it on L2PcInstance, addSubClass method

 

Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 268)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -11554,6 +11554,13 @@
			if (_transformation != null)
				return false;

+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_GLOVES);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_CHEST);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_CLOAK);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_FEET);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_LEGS);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_HEAD);
+			
			// Remove active item skills before saving char to database
			// because next time when choosing this class, weared items can
			// be different

  • 0
Posted

try adding it on L2PcInstance, addSubClass method

 

Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 268)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -11554,6 +11554,13 @@
			if (_transformation != null)
				return false;

+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_GLOVES);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_CHEST);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_CLOAK);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_FEET);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_LEGS);
+			this.getInventory().unEquipItemInSlot(Inventory.PAPERDOLL_HEAD);
+			
			// Remove active item skills before saving char to database
			// because next time when choosing this class, weared items can
			// be different

if i may suggest something, try to avoid L2PcInstance for such things, also, better would be something like that:

for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++)
getInventory().unEquipItemInSlot(i);

 

also u can do thread to equip those items after some time for example:

 

private class EquipItems implements Runnable
{
@Override
public void run()
{
for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++)
getInventory().equipItemInSlot(i);
}
}

and u apply it with:

ThreadPoolManager.getInstance.scheduleGeneral(new EquipItems(), timeInMilis);

hf :)

  • 0
Posted

if i may suggest something, try to avoid L2PcInstance for such things, also, better would be something like that:

for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++)
getInventory().unEquipItemInSlot(i);

 

also u can do thread to equip those items after some time for example:

 

private class EquipItems implements Runnable
{
@Override
public void run()
{
for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++)
getInventory().equipItemInSlot(i);
}
}

and u apply it with:

ThreadPoolManager.getInstance.scheduleGeneral(new EquipItems(), timeInMilis);

hf :)

 

for(int i = 0;i<Inventory.PAPERDOLL_TOTALSLOTS;i++)

getInventory().equipItemInSlot(i);

 

It won't work since these items are not equiped. He must create a list type of L2ItemInstance and add these items in ( so it will need L2PcInstance ) , then after x time just equip the items from the list and clear the list.

  • 0
Posted

^Wyatt solution is the most simple and accurate, you can drop "this." as it's optional, but else, it's the only decent solution.

 

- PAPERDOLL_TOTALSLOTS means you unequip the 20 slots, when we need to drop only main pieces.

- you equipItemInSlot( when it should be unEquipItemInSlot(... I guess you simply misread. Anyway.

- the task is useless as there is no need to delay.

  • 0
Posted

Hello i need one java code which when you change subclass you put off the armor to avoid bugs

you can make this:
player.getInventory().reloadEquippedItems();

or you can make

if (player.getActiveWeaponInstance() != null || player.getActiveShieldInstance() != null)
					player.disarmWeapons();

				if (player.getActiveChestArmorItem() != null)
				{
					final L2ItemInstance chest = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
					if (chest != null)
			    	{
			    		final L2ItemInstance[] unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(chest.getItem().getBodyPart());
			    		final InventoryUpdate iu = new InventoryUpdate();
			    		for (L2ItemInstance element : unequipped)
			    			iu.addModifiedItem(element);
			    		sendPacket(iu);
			    	}
				}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...