Jump to content
  • 0

Problem With Custom Donator/hero System


Question

Posted
Hi, i am using L2jFrozen and i tried to use this system but it seems that i cant get it to work :/


 

The donator item was causing troubles but i aplied the fix suggested on this topic and it solved the problem.

 

Now the problem is with hero item, let me explain...

if i use hero coin i get hero status etc just fine and i see the database update my hero end date as it should

when i relog i am no longer a hero BUT in database i can still see hero value 1 and my remaining time

also if i try to use hero coin again then donator coin in some point the data in DB get messed up, it set hero 0 and updates the donator end time and the opposit....

 

Did anyone have this problem or have any idea what can be the issue??

 

Thanks in advance!

3 answers to this question

Recommended Posts

  • 0
Posted (edited)

Sounds like a missing crap @ EnterWorld or messy PcInstance, the 'load' part.

Edited by SweeTs
  • 0
Posted (edited)

I didnt touch enterworld at all.

Plus that if hero_end_date is 0 (witch is forever) the character logs in as a hero normally no problem.

 

maybe there is something wrong here?

 

HeroCustomItem.java

 			if(player == null)
 				return;
 
-			con = L2DatabaseFactory.getInstance().getConnection(false);
-			PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
-
+			con = L2DatabaseFactory.getInstance().getConnection(false);			
+			
+			PreparedStatement stmt = con.prepareStatement(INSERT_DATA);			
+			
 			stmt.setInt(1, player.getObjectId());
 			stmt.setString(2, player.getName());
 			stmt.setInt(3, 1);
 			stmt.setInt(4, player.isNoble() ? 1 : 0);
 			stmt.setInt(5, player.isDonator() ? 1 : 0);
-			stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
+			
+			if (player.isHero())
+			{
+				stmt.setLong(6, player.getHeroDate(player.getObjectId()) + heroTime);
+			}
+			else
+			{
+				stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
+			}
+			
+			stmt.setLong(7, player.isDonator() ? 0 : player.getDonatorDate(player.getObjectId()));
 			stmt.execute();
 			stmt.close();
 			stmt = null;

and here is the part for L2PcInstance.java

+	
 	/**
+	 * Gets Hero end time
+	 * 
+	 * @return time, 0 if time is infinitive, or -1 if error
+	 */
+	
+	public long getHeroDate(int obj_Id)
+	{
+		Connection con = null;
+		int out = -1;
+		
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection(false);
+			PreparedStatement stmt = con.prepareStatement("SELECT hero_end_date FROM characters_custom_data WHERE obj_Id=" + obj_Id);
+			ResultSet rs = stmt.executeQuery();
+			if (rs.next())
+			{
+				out = rs.getInt(1);
+			}
+			rs.close();
+			rs = null;
+			stmt.close();
+			stmt = null;
+		}
+		catch (Exception e) {
+			if(Config.ENABLE_ALL_EXCEPTIONS)
+				e.printStackTrace();
+			
+			_log.log(Level.SEVERE, "Error: could not get hero_end_date from database: ", e);
+		}
+		finally {
+			CloseUtil.close(con);			
+			con = null;
+		}
+		return out;
+	}
+	
+	/**

btw thanks for ur interest in this :)

Edited by satanoula

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • TP Data: X=150148 Y=203643 Z=-3634
    • Hello everyone, this is ADENA L2REBORN / LU4 / MASTERWORK We also have items, epics, etc. discord - adver745645 Our prices are reasonable, so have a nice shopping and a nice day.
    • Dear friends, we are pleased to announce great news — we are launching our new bot for purchasing and renting virtual numbers for receiving SMS from any services! Are you tired of reused or resold numbers from other platforms? Try our solution! Our service allows you to receive SMS from any major popular services. The list includes more than 200 services! SMS receiving country: USA (+1). Real physical US numbers are used — never previously used on other platforms! Currently, only short-term rental is available. The rental duration for each phone number is shown when purchasing. The cost of each number is also shown next to the service before purchase. You can also receive an additional SMS for your number for the selected service (no extra charge for receiving one more SMS). To quickly find the service you need, you can use the convenient search — just type the name of the service you need and get a number for activation. Available payment methods: cryptocurrencies, bank cards, and balance transfer from our other bots. Thank you for your trust! Active links: Virtual Number Service: Go Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: 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 using 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 ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! 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 Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear friends, we are pleased to announce great news — we are launching our new bot for purchasing and renting virtual numbers for receiving SMS from any services! Are you tired of reused or resold numbers from other platforms? Try our solution! Our service allows you to receive SMS from any major popular services. The list includes more than 200 services! SMS receiving country: USA (+1). Real physical US numbers are used — never previously used on other platforms! Currently, only short-term rental is available. The rental duration for each phone number is shown when purchasing. The cost of each number is also shown next to the service before purchase. You can also receive an additional SMS for your number for the selected service (no extra charge for receiving one more SMS). To quickly find the service you need, you can use the convenient search — just type the name of the service you need and get a number for activation. Available payment methods: cryptocurrencies, bank cards, and balance transfer from our other bots. Thank you for your trust! Active links: Virtual Number Service: Go Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store through Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing goods and services from our platform: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, Bot) during October! You can also use the promo code for your first purchase: 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 using 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 ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! 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 Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • 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