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, right now we are holding a grand competition with a prize fund of more than $ 1000 in our stores https://socnet.store , telegram store: https://socnet.shop and SMM panel: https://socnet.pro There are more than 50 prize places in our competition, each lucky person can take one of the places. Important condition: you must make a purchase at any time before June 1, 2025. The more purchases you make - the more chances you have to win the main prize in the community of $ 300! ➡ Our Online Shop: socnet.store  ➡ Our SMM-Boosting Panel: socnet.pro  ➡ Telegram Shop Bot: socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: 79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
    • Dear friends, right now we are holding a grand competition with a prize fund of more than $ 1000 in our stores https://socnet.store , telegram store: https://socnet.shop and SMM panel: https://socnet.pro There are more than 50 prize places in our competition, each lucky person can take one of the places. Important condition: you must make a purchase at any time before June 1, 2025. The more purchases you make - the more chances you have to win the main prize in the community of $ 300! ➡ Our Online Shop: socnet.store  ➡ Our SMM-Boosting Panel: socnet.pro  ➡ Telegram Shop Bot: socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: 79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
    • REBORN ETERNAL IL x10 WTS  1gb 8e (a lot in stock) DR set +6 180e Frintezza+6 200e Zaken+6 200e AQ+6 200e You must go first or Pufa middleman service
    • There's many reasons why it would be more NO than YES : Using NCSoft assets is a death wish, they can lawyer any LU3/Unity if they wanted, since it's a plain steal of intellectual property. It's an hobby, as you said it, and it's not specially about money. Money is a way to filter idiots/resellers, nothing more. It's really about trying to replicate old content and optimize it which I find it fun. I just align with the basic idea than an emulator emulates. When you launch Project64 and SuperMario 64, you don't expect to get something more than 120 stars and Bowser boss in the end - which should have been L2J project to begin with Even if I played a lot with TESCS from Morrowind, back in time, it's not enough to handle current engines, and I'm too lazy to learn Unity/Unreal Engine. Moreover, it would mean buying assets. While doing it alone would be a fail, coupling to L2J / L2 community would still be shitty (since the majority is RU/BR) ; people is only about fame/glory/reselling shit on back of others. Opening to others, the project would be leaked day 1, rebranded and resold. MMO genre is basically dead, and that's not a reboot of any game (l2/wow classic :D) which will turn the tide. Regarding L2 or an remastered version of it, you can obviously blatantly copy-cat it (as Propnight did for Dead by daylight).   All frenchies aren't supposed to do Expedition 33 :).
    • 190euro until last month, don't miss it.
  • 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