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>();

 

 

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