Jump to content

Recommended Posts

Posted (edited)

Hello guys! I adapted the code about "Cannot Enchant near Warehouse"

I found the code by Prince*

I adapted this code for Frozen...

Try it and tell me if it's working good because i didn't check it.

Thank you :)

 

"I know it wasn't hard to adapt it but i wanted to share it for frozen because some guys don't know how to do it... Peace :)"

 

--- head-src/com/l2jfrozen/gameserver/clientpackets/RequestEnchantItem.java
+++ head-src/com/l2jfrozen/gameserver/clientpackets/RequestEnchantItem.java

@@ 20,1 @@

import com.l2jfrozen.Collection;
import com.l2jfrozen.Logger;

import com.l2jfrozen.gameserver.model.Inventory;
+import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.model.L2ItemInstance;


import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.actor.instance.L2WarehouseInstance;
import com.l2jfrozen.gameserver.network.SystemMessageId;


import com.l2jfrozen.gameserver.model.L2ItemInstance;
+import com.l2jfrozen.gameserver.model.L2Object;
import com.l2jfrozen.gameserver.model.L2World;


@@ -61,7 +61,15 @@
     {
         L2PcInstance activeChar = getClient().getActiveChar();
+               Collection<L2Character> knowns  = activeChar.getKnownList().getKnownCharactersInRadius(400);
         if (activeChar == null || _objectId == 0)
                        return;
+              
+               for (L2Object wh : knowns)
+               {
+                       if (wh instanceof L2WarehouseInstance)
+                       {
+                               activeChar.sendMessage("You cannot enchant near warehouse.");
+                               return;
+                       }
+               }
         L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
         L2ItemInstance scroll = activeChar.getActiveEnchantItem();

 

 

Edited by Kounto
Posted

Put that

activeChar.getKnownList().getKnownCharactersInRadius(400)

directly in the for loop . First because it's a good writting style to write things in the shortest range possible (faster ready for garbage collection), second because you put it before a activeChar == null check, so it will throw a NPE if activeChar is null.

Posted
  On 2/13/2018 at 3:46 AM, L2DragonWind said:

Why need this?

Expand  

You cannot enchant near warehouse... Before some years it was a bug. Now i don't know if you can use this bug but i think this code is useful about your safety.

Posted

About the coding style you can just add after the null activechar check the following:

 

if (activeChar.getKnownList().getKnownCharactersInRadius(400).stream().filter(obj -> obj instanceof L2WarehouseInstance).findFirst())
{
	activeChar.sendMessage("You cannot enchant near warehouse.");
	return;
}

About the results.. In order someone to use this code must have old sources that missing important fixes

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.



  • Posts

    • MoMoProxy Offers $850 for 1TB Plan. anyone interested in can view details as follow: https://momoproxy.com/residential-proxies
    • Yes there are many problems. Im trying to fix there slowly, cause i i put already a lot of work in this files. I think it will not be easy to move the project to other builds
    • You probably wanted to write l2jmobius. I would recommend that you change the build because it has a lot of problems with the movement of npcs and players. Even if you find bots you will have to correct the movement or the bots will get stuck, fly, teleport
    • Complete Server Pack + Source Files: C4 Scions Of Destiny: P656 Retail X1 L2OFF Server Pack + Source: Price: 100EUR --------------------------------------------------------------------------------------------------------------------------------------------- C4 Scions Of Destiny: P656 ESL2 Athena x45 L2OFF Server Pack + Source: Price: 150EUR -------------------------------------------------------------------------------------------------------------------------------------------- C6 Interlude: P756 ESL2 Athena x45 L2OFF Server Pack + Source: Price: 150EUR The same as C4 but in C6 Client  ----------------------------------------------------------------------------------------------------------------------------------------------   C6 Interlude: P746 L2Gold L2OFF Server Pack + Source: Price: 150EUR   https://imgur.com/a/pts-l2gold-interlude-p746-9kB3oA9#MbP2aJh -------------------------------------------------------------------------------------------------------------------------------------------------   C6 - Classic Interlude: P110 ESL2 Athena x45 L2OFF Server Pack + Source: Price: 350EUR   https://imgur.com/a/pts-l2off-p110-classic-interlude-athena-x45-Z2kZxuv#YlZU9hF -------------------------------------------------------------------------------------------------------------------------------------------------   DISCORD - MMOPROMOOO TELEGRAM - MMOPROMO 
    • Wts adena scryde x50 Baium 12 Valakas 12 good price Top weapons +16
  • Topics

×
×
  • Create New...