Jump to content

Recommended Posts

Posted

Well as the title says this is a patch to fix the multisell quantity bug when a player is trying to buy

an amount of item that exceeding the slots in his inventory or either exceeding his current weight limit.

 

Example without patch: lets say you got 80 maximum slots and u go to buy 81 or more blessed scrolls from your

custom multisell. Well in my case without this patch after the items was created in your inventory

your client was getting crashed and keep crashing on login until u clear those items from your database.

 

Example with patch: again you got 80 maximum slots and u go to buy 81 or more blessed scrolls from your custom

multisell. You will get a message "Your Inventory is full". or i you try to buy something that u could get more

than 100% weight limit you will get a message "You exceeded your Weight Limit."

 

Tested and working with core L2j Server Interlude rev4709 but im sure this will work in other cores too...

A note that this patch maybe already applied to your core so just ignore it.!

Hope this helps u..!

 

Index: java/net/sf/l2j/gameserver/clientpackets/MultiSellChoose.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/MultiSellChoose.java	(revision 4507)
+++ java/net/sf/l2j/gameserver/clientpackets/MultiSellChoose.java	(working copy)
@@ -97,6 +97,36 @@

         MultiSellEntry entry = prepareEntry(merchant, templateEntry, applyTaxes, maintainEnchantment, enchantment);

+        /** Fix that checks if the amount to be purchased 
+        is exceeding the slots or weight limit and 
+        returns a message to the player [Custom] */
+		
+		int slots = 0;
+		int weight = 0;
+		for (MultiSellIngredient e : entry.getProducts())
+		{
+			if (e.getItemId() < 0)
+				continue;
+			L2Item template = ItemTable.getInstance().getTemplate(e.getItemId());
+			if (template == null)
+				continue;
+			if (!template.isStackable())
+				slots += e.getItemCount() * _amount;
+			else if (player.getInventory().getItemByItemId(e.getItemId()) == null)
+				slots++;
+			weight += e.getItemCount() * _amount * template.getWeight();
+		}
+		if (!inv.validateWeight(weight))
+		{
+			player.sendPacket(new SystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
+			return;
+		}
+		if (!inv.validateCapacity(slots))
+		{
+			player.sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
+			return;
+		}
+		
         // Generate a list of distinct ingredients and counts in order to check if the correct item-counts
         // are possessed by the player
     	FastList<MultiSellIngredient> _ingredientsList = new FastList<MultiSellIngredient>();

 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..