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

    • Dear friends, we are glad to present our new service — KYC verification for any platforms!️ We verify crypto exchanges, marketplaces, social networks, hosting providers, casinos, and other legitimate websites. Verification is done using a passport or driver’s license. Services engaged in illegal activity are not supported. Available countries: Eastern Europe: Russia, Ukraine, Belarus, Uzbekistan, Armenia, Kyrgyzstan, Kazakhstan — $30–33 European Union (Western Europe, often Latvia and Estonia) — $80–88 Africa: Nigeria, Kenya — $30–33 If you need both registration and verification of your account, an additional 10% fee is applied to the transaction amount. Contact us to request KYC verification or for other support inquiries: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store Active SOCNET Store Links: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable way to buy Telegram Stars. SMM Panel: Go – promote your social media accounts. We would like to present you the current list of promotions and special offers for purchasing our products and services: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during September! You can also use the first-time promo code SOCNET (15% discount). 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." – post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a support ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Telegram bot for Star purchases! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh
    • Dear friends, we are glad to present our new service — KYC verification for any platforms!️ We verify crypto exchanges, marketplaces, social networks, hosting providers, casinos, and other legitimate websites. Verification is done using a passport or driver’s license. Services engaged in illegal activity are not supported. Available countries: Eastern Europe: Russia, Ukraine, Belarus, Uzbekistan, Armenia, Kyrgyzstan, Kazakhstan — $30–33 European Union (Western Europe, often Latvia and Estonia) — $80–88 Africa: Nigeria, Kenya — $30–33 If you need both registration and verification of your account, an additional 10% fee is applied to the transaction amount. Contact us to request KYC verification or for other support inquiries: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store Active SOCNET Store Links: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable way to buy Telegram Stars. SMM Panel: Go – promote your social media accounts. We would like to present you the current list of promotions and special offers for purchasing our products and services: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during September! You can also use the first-time promo code SOCNET (15% discount). 2. Get $1 credited to your store balance or a 10–20% discount — simply post your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." – post it in our forum thread! 3. Get $1 for your first SMM Panel trial — just open a support ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Telegram bot for Star purchases! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh
  • 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