Jump to content

Recommended Posts

Posted

Hello! Today, I made my second code!

 

It's an item, which gives you Donator's Status.

 

The id of the item is 6673, if you want change it.

 

### Eclipse Workspace Patch 1.0
#P L2jFrozen_Gs
Index: head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java	(revision 946)
+++ head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java	(working copy)
@@ -65,6 +66,7 @@
import com.l2jfrozen.gameserver.handler.itemhandlers.SpecialXMas;
import com.l2jfrozen.gameserver.handler.itemhandlers.SpiritShot;
import com.l2jfrozen.gameserver.handler.itemhandlers.SummonItems;
+import com.l2jfrozen.gameserver.handler.itemhandlers.VipItem;

/**
  * This class manages handlers of items
@@ -144,6 +147,7 @@
		registerItemHandler(new ExtractableItems());
		registerItemHandler(new SpecialXMas());
		registerItemHandler(new SummonItems());
+		registerItemHandler(new VipItem());
		registerItemHandler(new BeastSpice());
		registerItemHandler(new JackpotSeed());
		registerItemHandler(new NobleCustomItem());

### Eclipse Workspace Patch 1.0
#P L2jFrozen_Gs
Index: head-src/com/l2jfrozen/gameserver/handler/itemhandlers/VipItem.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/handler/itemhandlers/VipItem.java	(revision 0)
+++ head-src/com/l2jfrozen/gameserver/handler/itemhandlers/VipItem.java	(working copy)
@@ -0,0 +1,145 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jfrozen.gameserver.handler.itemhandlers;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import com.l2jfrozen.Config;
+import com.l2jfrozen.gameserver.handler.IItemHandler;
+import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
+import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.actor.instance.L2PlayableInstance;
+import com.l2jfrozen.util.CloseUtil;
+import com.l2jfrozen.util.database.L2DatabaseFactory;
+
+/**
+ * @author Crystalia
+ *
+ */
+public class VipItem implements IItemHandler
+{
+
+	private static final int ITEM_IDS[] = {
+        6673
+    };
+
+	@Override
+	public int[] getItemIds()
+    {
+        return ITEM_IDS;
+    }
+
+	private void updateDatabase(L2PcInstance player, boolean newDonator)
+	{
+		Connection con = null;
+		try
+		{
+			// prevents any NPE.
+			// ----------------
+			if(player == null)
+				return;
+
+			// Database Connection
+			//--------------------------------
+			con = L2DatabaseFactory.getInstance().getConnection(false);
+			PreparedStatement stmt = con.prepareStatement(newDonator ? INSERT_DATA : DEL_DATA);
+
+			// if it is a new donator insert proper data
+			// --------------------------------------------
+			if(newDonator)
+			{
+				stmt.setInt(1, player.getObjectId());
+				stmt.setString(2, player.getName());
+				stmt.setInt(3, player.isHero() ? 1 : 0);
+				stmt.setInt(4, player.isNoble() ? 1 : 0);
+				stmt.setInt(5, 1);
+				stmt.execute();
+				stmt.close();
+				stmt = null;
+			}
+			else
+			// deletes from database
+			{
+				stmt.setInt(1, player.getObjectId());
+				stmt.execute();
+				stmt.close();
+				stmt = null;
+			}
+		}
+		catch(Exception e)
+		{
+			if(Config.ENABLE_ALL_EXCEPTIONS)
+				e.printStackTrace();
+			
+			
+		}
+		finally
+		{
+			CloseUtil.close(con);
+		}
+	}
+
+	// Updates That Will be Executed by MySQL
+	// ----------------------------------------
+	String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator) VALUES (?,?,?,?,?)";
+	String DEL_DATA = "UPDATE characters_custom_data SET donator = 0 WHERE obj_Id=?";
+	
+	@Override
+	public void useItem(L2PlayableInstance playable, L2ItemInstance item)
+	{
+		if(!(playable instanceof L2PcInstance))
+            return;
+        L2PcInstance activeChar = (L2PcInstance)playable;
+        
+        	if(activeChar.isDonator())
+        	{
+        	activeChar.sendMessage("You are already a donator.You cannot use that item.");
+        	return;
+        	playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
+        	activeChar.setDonator(true);
+        	updateDatabase(activeChar, true);
+        	activeChar.sendMessage("Thanks for using our item in order to be server's donator.");
+            activeChar.broadcastUserInfo();
+        
+		
+	}
+	
+}
\ No newline at end of file

 


 

PS; It's not tested, if someone can give feedback I would be greatful.

 


 

Thanks Elfocrash, for his help in this code!

 


Posted

meh, try to do something more interesting, setting hero and noble while clicking on item isnt anything special..

Posted

meh, try to do something more interesting, setting hero and noble while clicking on item isnt anything special..

Dude, it's my first try in java. I don't know to make 'super' things, but with the time I will learn more and more.

 

I will try, to make something new. Thanks!

Posted

Yeah! I Have it at my server. :)

Are you sure? Show me the config or the code.

 

I searched l2jfrozen's source and there isn't any code about this item.

 

Waiting proofs.

Posted

I had it at my server.

C:\server\gameserver\config\functions\l2jfrozen.properties

# -----------------------------------------------------
# Donator Custom Item Configuration -
# -----------------------------------------------------
# When ActiveChar will use this item will be Donator.
EnableDonatorCustomItem = True
# Id Item Need's 
DonatorCustomItemId = 6673

Posted

YOU passed it. In retail l2jfrozen this code isn't exist.

 


 

http://subversion.assembla.com/svn/L2jFrozenInterlude/trunk/gameserver/config/functions/l2jfrozen.properties -> Current Revision (l2jfrozen.properties)

 


I don't have source. I don't use eclipse because I don't understand how to do it.

  • 1 month later...
Posted

My Code 100times easier

//Donator Custom item by Leki

package com.l2jfrozen.gameserver.handler.itemhandlers;

import com.l2jfrozen.gameserver.handler.IItemHandler;
import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jfrozen.gameserver.network.serverpackets.SocialAction;

public class DonateCustomItem implements IItemHandler
{

public DonateCustomItem()
{
//null
}

@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
		if(!(playable instanceof L2PcInstance))
			return;

		L2PcInstance activeChar = (L2PcInstance) playable;

		if(activeChar.isInOlympiadMode())
		{
			activeChar.sendMessage("This item can not be used on olympiad");
		}

		if(activeChar.isDonator())
		{
			activeChar.sendMessage("You are already the donator member");
		}
		else
		{
			activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 16));
			activeChar.setDonator(true);;
			activeChar.sendMessage("You are donator member now!");
			activeChar.broadcastUserInfo();
			playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
		}
		activeChar = null;
}

@Override
public int[] getItemIds()
{
	return ITEM_IDS;
}

private static final int ITEM_IDS[] =
{
	6673
};

}

Posted

My Code 100times easier

//Donator Custom item by Leki

package com.l2jfrozen.gameserver.handler.itemhandlers;

import com.l2jfrozen.gameserver.handler.IItemHandler;
import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jfrozen.gameserver.network.serverpackets.SocialAction;

public class DonateCustomItem implements IItemHandler
{

public DonateCustomItem()
{
//null
}

@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
		if(!(playable instanceof L2PcInstance))
			return;

		L2PcInstance activeChar = (L2PcInstance) playable;

		if(activeChar.isInOlympiadMode())
		{
			activeChar.sendMessage("This item can not be used on olympiad");
		}

		if(activeChar.isDonator())
		{
			activeChar.sendMessage("You are already the donator member");
		}
		else
		{
			activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 16));
			activeChar.setDonator(true);;
			activeChar.sendMessage("You are donator member now!");
			activeChar.broadcastUserInfo();
			playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
		}
		activeChar = null;
}

@Override
public int[] getItemIds()
{
	return ITEM_IDS;
}

private static final int ITEM_IDS[] =
{
	6673
};

}

You don't even use database part.

 

Also, where is registering?

Guest
This topic is now closed to further replies.


  • Posts

    • Would it be possible to update the guide? The images are offline! 😞
    • In the fast-paced world of digital marketing, having the right tools makes all the difference. If you're searching for a reliable SMM panel Nigeria, GoUpSocial is here to take your online presence to the next level. Built for influencers, marketers, startups, and content creators, our platform is the ultimate solution for smart and scalable social media growth. With GoUpSocial, you get more than just numbers—you get engagement that drives real impact. As a trusted Nigerian SMM panel, we help you gain visibility across top platforms like Instagram, TikTok, YouTube, Facebook, and Twitter—all at the most competitive prices in the market. Experience the Power of the Best SMM Panel in Nigeria We understand that quality matters just as much as affordability. That’s why GoUpSocial has become the go-to platform for users seeking the best SMM panel in Nigeria. Here’s what makes us the preferred choice: 🚀 Real-Time Delivery: Get your orders processed and completed in minutes, not hours. 💼 All-in-One Dashboard: Manage all your campaigns with ease from a clean, simple interface. 💡 Effective Strategies: Our tools are tailored for organic-looking growth and high user engagement. 🧾 Transparent Pricing: No hidden fees—just straightforward, affordable packages. 👩‍💻 Expert Support: Our team is available 24/7 to guide you through every step of the process. Whether you need more followers, likes, views, or overall engagement, our SMM panel Nigeria services deliver measurable and meaningful results. Why We’re the Nigeria Fastest and Cheapest SMM Panel GoUpSocial isn’t just another provider—it’s the Nigeria fastest and cheapest SMM panel built with performance and value in mind. We combine automation, intelligent targeting, and local market understanding to help you scale effortlessly. Need to boost a campaign today? Our platform supports instant order processing, real-time tracking, and localized engagement strategies—making it ideal for any influencer or business operating in Nigeria. Plus, as the cheapest SMM panel in Nigeria, we make sure that even clients with limited budgets can access top-quality services without compromise. A Nigerian SMM Panel Built for 2025 and Beyond As social media algorithms evolve, traditional methods of gaining reach and engagement no longer work. That’s why we’ve built the SMM panel Nigeria 2025—a next-gen platform optimized for today’s challenges. From smart delivery settings to niche-specific targeting, GoUpSocial provides you with every advantage in a competitive digital world. Our system adapts to the latest platform changes, helping you stay relevant, visible, and in control. Looking for a localized service? Our SMM panel for Nigerian followers helps you connect directly with your audience—boosting both credibility and conversions. All-in-One Online Panel in Nigeria for Every Social Goal No matter your objective—brand awareness, follower growth, or engagement improvement—GoUpSocial is the online panel in Nigeria that offers it all. With flexible services, dynamic campaigns, and secure systems, we give you the tools to succeed in a crowded online space. And because we’re committed to your growth, our platform is continually updated to reflect the best practices of modern digital marketing. Take the Leap with the Best Nigerian SMM Panel Ready to grow smarter? With GoUpSocial, you don’t just gain social proof—you build real influence. As the cheapest Nigeria SMM panel, we combine speed, quality, and affordability in one seamless platform. Whether you're an aspiring influencer, a marketing agency, or a brand aiming for greater reach, GoUpSocial is the ultimate Nigerian SMM panel to help you reach your full potential. 👉 Sign up today and unlock the next level of social media growth with GoUpSocial.
    • Lineage2 : Website Download now our System Patch. Registration from 12:00 UTC Time.
    • Daily reward system operational. 28 rewards. Option to buy days (Donate). Automatically resets on the first day of each month. External configuration file. You can submit daily rewards by account or IP. Minimum claim level. Claiming on the 28th locks the reward until the next month. Contact Discord: lykoz#0331
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock