Jump to content

UseItem exploit fix (duplicate items) - ALL L2J VERSIONS


Tryskell

Recommended Posts

You got twice the same section of code, using both L2J old version and aCis version. Delete

 

			if (activeChar.isAttackingNow())
			{
				ThreadPoolManager.getInstance().scheduleGeneral(new WeaponEquipTask(item, activeChar), (activeChar.getAttackEndTime() - GameTimeController.getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
				return;
}

and the associated class.

Link to comment
Share on other sites

1 hour ago, Tryskell said:

You got twice the same section of code, using both L2J old version and aCis version. Delete

 


			if (activeChar.isAttackingNow())
			{
				ThreadPoolManager.getInstance().scheduleGeneral(new WeaponEquipTask(item, activeChar), (activeChar.getAttackEndTime() - GameTimeController.getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
				return;
}

and the associated class.

 

Thanks, later I will setup a test server and test this bug again.

Link to comment
Share on other sites

  • 2 weeks later...
On 2/10/2019 at 2:05 PM, Tryskell said:

You got twice the same section of code, using both L2J old version and aCis version. Delete

 


			if (activeChar.isAttackingNow())
			{
				ThreadPoolManager.getInstance().scheduleGeneral(new WeaponEquipTask(item, activeChar), (activeChar.getAttackEndTime() - GameTimeController.getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
				return;
}

and the associated class.


The fix worked!

For anyone else struggling, here's what I did on my older aCis rev:
 

 

diff --git a/UseItem.java b/UseItem.java
index de97950..9bec237 100644
--- a/UseItem.java
+++ b/UseItem.java
@@ -46,32 +46,6 @@
 	private boolean _ctrlPressed;
 	private int _itemId;
 	
-	/** Weapon Equip Task */
-	public static class WeaponEquipTask implements Runnable
-	{
-		L2ItemInstance item;
-		L2PcInstance activeChar;
-		
-		public WeaponEquipTask(L2ItemInstance it, L2PcInstance character)
-		{
-			item = it;
-			activeChar = character;
-		}
-		
-		@Override
-		public void run()
-		{
-			// If character is still engaged in strike we should not change weapon
-			if (activeChar.isAttackingNow())
-			{
-				return;
-			}
-			
-			// Equip or unEquip
-			activeChar.useEquippableItem(item, false);
-		}
-	}
-	
 	@Override
 	protected void readImpl()
 	{
@@ -318,13 +292,7 @@ protected void runImpl()
 			// Don't allow Hero items equipment if not a hero
 			if (!activeChar.isHero() && (((item.getItemId() >= 6611) && (item.getItemId() <= 6621)) || (item.getItemId() == 6842)) && !activeChar.isGM())
 				return;
-			
-			if (activeChar.isAttackingNow())
-			{
-				ThreadPoolManager.getInstance().scheduleGeneral(new WeaponEquipTask(item, activeChar), (activeChar.getAttackEndTime() - GameTimeController.getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
-				return;
-			}
-			
+	
 			if (!GameProperties.ALLOW_DAGGERS_WEAR_HEAVY)
 			{
 				if ((activeChar.getClassId().getId() == 93) || (activeChar.getClassId().getId() == 108) || (activeChar.getClassId().getId() == 101) || (activeChar.getClassId().getId() == 8) || (activeChar.getClassId().getId() == 23) || (activeChar.getClassId().getId() == 36))
@@ -358,7 +326,15 @@ protected void runImpl()
 				}
 			}
 			
-			// Equip or unEquip
+		    if (activeChar.isAttackingNow())
+			ThreadPoolManager.getInstance().scheduleGeneral(() -> {
+			    final L2ItemInstance itemToTest = activeChar.getInventory().getItemByObjectId(_objectId);
+			    if(itemToTest == null)
+				return;
+
+			    activeChar.useEquippableItem(itemToTest, false);
+			}, activeChar.getAttackEndTime() - System.currentTimeMillis());
+		    else
 			activeChar.useEquippableItem(item, true);
 		}
 		else

 

Edited by zemaitis
Link to comment
Share on other sites

  • 1 year later...
10 hours ago, heladito said:

hi! how can i add into Frozen?

 

If L2JFrozen got the related task, then simply make it manually following the diff patch. + means it's added, - removed.

 

You would probably be interested by my other exploit fix, regarding Enterworld and ENTERING implementation.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   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...