Jump to content
  • 0

[HELP]Help me fix That Boss Info Npc to H5


Question

Posted

/*
* 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 custom.BossRespawn;


import javolution.text.TextBuilder;

import com.l2jserver.gameserver.instancemanager.GrandBossManager;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.datatables.NpcTable;

public class BossRespawn extends Quest
{
private static final int NPC_ID = 93000;
private static final int[] BOSSES = {29001, 29006, 29014, 29019, 29020, 29022, 29028, 29045};

public BossRespawn(int questid, String name, String descr)
{
	super(questid, name, descr);
	addFirstTalkId(NPC_ID);
}

public String onFirstTalk(L2Npc npc, L2PcInstance pc)
{
	if(npc == null || pc == null)
		return null;

	if(npc.getNpcId() == NPC_ID)
	{
		sendInfo(pc);
	}
		return null;
}

private void sendInfo(L2PcInstance activeChar)
{
	TextBuilder tb = new TextBuilder();
	tb.append("<html><title>Grand Boss Info By Dleogr</title><body><br><center>");
	tb.append("<img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>");

	for(int boss : BOSSES)
	{
		String name = NpcTable.getInstance().getTemplate(boss).getName();
		long delay = GrandBossManager.getInstance().getStatsSet(boss).getLong("respawn_time");
		if (delay <= System.currentTimeMillis())
		{
			tb.append("<font color=\"00C3FF\">" + name + "</color>: " + "<font color=\"9CC300\">Is Alive</color>"+"<br1>");
		}
		else
		{
			int hours = (int) ((delay - System.currentTimeMillis()) / 1000 / 60 / 60);
			int mins = (int) (((delay - (hours * 60 * 60 * 1000)) - System.currentTimeMillis()) / 1000 / 60);
			int seconts = (int) (((delay - ((hours * 60 * 60 * 1000) + (mins * 60 * 1000))) - System.currentTimeMillis()) / 1000);
			tb.append("<font color=\"00C3FF\">" + name + "</color>" + "<font color=\"FFFFFF\">" +" " + "Respawn in :</color>" + " " + " <font color=\"32C332\">" + hours + " : " + mins + " : " + seconts + "</color><br1>");
		}
	}

	tb.append("<br><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>");
	tb.append("</center></body></html>");

	NpcHtmlMessage msg = new NpcHtmlMessage(NPC_ID);
	msg.setHtml(tb.toString());
	activeChar.sendPacket(msg);
}

public static void main(String[] args)
{
	new BossRespawn(-1, "BossRespawn", "custom");
}
}

 

the script works on NPC but he only show's "ALIVE" :S

 

if you kill the Grand Boss like Baium etc. he always show alive.

9 answers to this question

Recommended Posts

  • 0
Posted

I'll give you the skeleton of the implementation

 

-Create a method for retrieving the data into a String(with all the html you want to generate)

-Put the above method on a ThreadPool and schedule it for a fixed rate(your choice on how many time until next refresh).

-Use the sendInfo method you got down there to send the above String to the player in an npc window.

Right now you don't refresh the content.

  • 0
Posted

sorry i dont know code as well :X can you help me do that plz? <3

 

should i do:

private static int refreshTime = 30

and

ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new reloadboss(), 1000, refreshTime);

 

and a private class reloadboss?

  • 0
Posted

should i do:

private static int refreshTime = 30

and

ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new reloadboss(), 1000, refreshTime);

 

and a private class reloadboss?

the private class well no.rest stuff yes.Oh and refreshTime*1000.Don't forget we are talking about milliseconds here.

  • 0
Posted

What's the point to use a task, it is updated automatically when you re-speak to the NPC.

 

So far, respawn_time == 0 means it's alive, if there is any respawn time, it means it's dead. Change your check for what I said.

  • 0
Posted

/*
* 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 custom.BossRespawn;


import javolution.text.TextBuilder;

import com.l2jserver.gameserver.instancemanager.GrandBossManager;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.datatables.NpcTable;

public class BossRespawn extends Quest
{
private static final int NPC_ID = 93000;
private static final int[] BOSSES = {29001, 29006, 29014, 29019, 29020, 29022, 29028, 29045};

public BossRespawn(int questid, String name, String descr)
{
	super(questid, name, descr);
	addFirstTalkId(NPC_ID);
}

public String onFirstTalk(L2Npc npc, L2PcInstance pc)
{
	if(npc == null || pc == null)
		return null;

	if(npc.getNpcId() == NPC_ID)
	{
		sendInfo(pc);
	}
		return null;
}

private void sendInfo(L2PcInstance activeChar)
{
	TextBuilder tb = new TextBuilder();
	tb.append("<html><title>Grand Boss Info By Dleogr</title><body><br><center>");
	tb.append("<img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>");

	for(int boss : BOSSES)
	{
		String name = NpcTable.getInstance().getTemplate(boss).getName();
		long delay = GrandBossManager.getInstance().getStatsSet(boss).getLong("respawn_time");
                                activeChar.sendMessage("Boss ID "+boss+" Current "+System.System.currentTimeMillis() +" delay "+delay);
		if (delay <= System.currentTimeMillis())
		{
			tb.append("<font color=\"00C3FF\">" + name + "</color>: " + "<font color=\"9CC300\">Is Alive</color>"+"<br1>");
		}
		else
		{
			int hours = (int) ((delay - System.currentTimeMillis()) / 1000 / 60 / 60);
			int mins = (int) (((delay - (hours * 60 * 60 * 1000)) - System.currentTimeMillis()) / 1000 / 60);
			int seconts = (int) (((delay - ((hours * 60 * 60 * 1000) + (mins * 60 * 1000))) - System.currentTimeMillis()) / 1000);
			tb.append("<font color=\"00C3FF\">" + name + "</color>" + "<font color=\"FFFFFF\">" +" " + "Respawn in :</color>" + " " + " <font color=\"32C332\">" + hours + " : " + mins + " : " + seconts + "</color><br1>");
		}
	}

	tb.append("<br><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>");
	tb.append("</center></body></html>");

	NpcHtmlMessage msg = new NpcHtmlMessage(NPC_ID);
	msg.setHtml(tb.toString());
	activeChar.sendPacket(msg);
}

public static void main(String[] args)
{
	new BossRespawn(-1, "BossRespawn", "custom");
}
}

Well i read this on the fly.Saw the "if you kill the Grand Boss like Baium etc. he always show alive" phrase and assumed it's not refreshed properly.I was wrong.Also the check is just fine.(If it's allive then delay-System.currentTimeMillis() will be negative or zero or if you like delay<=System.currentTimeMillis())  )

let's do somekind of debug.I've added a line below long delay = bla bla

See what message you will get after this add.You'll find out what's wrong

  • 0
Posted

gives error here: activeChar.sendMessage("Boss ID "+boss+" Current "+System.currentTimeMillis() +" delay "+delay);

 

 

wopsie it's System.currentTimeMillis()

edited in the quote

Guest
This topic is now closed to further replies.


  • Posts

    • Hi players ! Meet our project Lineage 2 Hiro Classic ! A low rate classic pvp oriented with many features. No pay to win, RB/AoE, group clan pvp castle etc ...  Dynamic rates, RB Xp 4x and soon massive update with auto farm ! Join now !  https://www.lineage2hiro.com/ Can't wait to see you online !
    • To all first time buyers we give a bonus + 10% of the order. 
    • 🔥 Looking for a powerful, clean, and player-friendly Auction House system for your Lineage 2 server? This fully-featured module is ready to plug into your project and provide your players with a modern, centralized marketplace!   💼 What is it? A complete Auction House system designed for fixed-price item sales between players. Forget about private stores and spammed zones—this system offers a smooth, secure, and offline-friendly way to buy and sell items across your server.   Photo Library: https://imgur.com/a/zLlUQbW   ✅ Main Features: 🔹 Fixed-Price Listings Only: Players list items at a set price. No bidding, no delays—just fast, clean trades. 🔹 Multi-Currency Support: Works with Adena, event coins, custom currencies—fully configurable. 🔹 Dynamic Interface: Players can filter items by name, type, and price. Easy-to-use HTML layout with smooth pagination. 🔹 Sell While Offline: Post items and receive payments even if you're not online—true passive trading. 🔹 Safety First: Full validation: no equipped/augmented/restricted items unless allowed. Prevents scams, mispricing, and listing errors. 🔹 Expiration Timer (Optional): Set listing time limits. Expired items go to warehouse/mail automatically. 🔹 Spam & Duplication Protection: Prevents multiple listings of identical items and unnecessary database load. 🔹 Performance Optimized: Clean, indexed SQL structure. No lag or bloating even with thousands of listings.   ⚙️ Plug & Play Clean Java code (compatible with aCis & derivatives). Easy setup with full instructions and sample configurations. Includes SQL, HTML files, and all Java classes – fully working out of the box.   💰 Pricing & Contact 📦 50 euro - One-time purchase with full support for setup & basic customization. 💬 Contact me here via PM or on Discord: @Luminous 🔐 Serious buyers only – source is clean, secure, and tested on live servers.     Give your server the next-level economy it deserves. No more chaotic trade zones. No more confusion. Just clean, efficient, server-wide trading.
    • We are certainly not an ambulance, but we will definitely cure you of blacklists and empty pockets. Live freely with SX! Each of you will receive a trial version of SX to familiarize yourself with the product, all you have to do is post in this thread
  • Topics

×
×
  • Create New...