Jump to content
  • 0

create npc top pvp / pk for l2jmobius interlude


Question

Posted

 

I would like to know if someone can generate a guide for me to create or adapt a npc top pvp / pk for l2jmobius interlude .. I have already tried it for days and I have not succeeded .. I would appreciate your help.

I'm going crazy with this ... and I also want to create the npc for the raid bosses ... from now on I thank you very much for your attention

2 answers to this question

Recommended Posts

  • 0
Posted

Sup dude, i'm using mobius to and i recommendation its just use the things you have on that pack, trying to add new npcs its a nightmare. The only way you can get new npcs and so on its paying for support and unlock more hidden post on mobius forum, ofc you will have to pay 120 euros.

  • 0
Posted (edited)
/*
 * This file is part of the L2J Mobius project.
 * 
 * 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 org.l2jmobius.gameserver.model.actor.instance;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.StringTokenizer;

import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.cache.HtmCache;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;

/**
 * @author Drazeal
 */
public class StatusInstance extends NpcInstance
{
	
	private class PlayerInfo
	{
		public PlayerInfo(int pos, String n, int pvps, int pks, int ontime, Boolean iso)
		{
			position = pos;
			Nick = n;
			pvpCount = pvps;
			pkCount = pks;
			onlineTime = ontime;
			isOnline = iso;
		}
		
		public int position;
		public String Nick;
		public int pvpCount;
		public int pkCount;
		public int onlineTime;
		public Boolean isOnline;
	}
	
	// delay interval (in minutes):
	private final int delayForCheck = 5;
	
	// number of players to be listed
	private final int pvpListCount = 10;
	private final int pkListCount = 10;
	private final int onlineListCount = 10;
	
	private final PlayerInfo[] topPvPList = new PlayerInfo[pvpListCount];
	private final PlayerInfo[] topPkList = new PlayerInfo[pkListCount];
	private final PlayerInfo[] topOnlineList = new PlayerInfo[onlineListCount];
	
	public StatusInstance(NpcTemplate template)
	{
		super(template);
		setInstanceType(InstanceType.StatusInstance);
		ThreadPool.scheduleAtFixedRate(new RefreshAllLists(), 10000, delayForCheck * 60000);
	}
	
	private class RefreshAllLists implements Runnable
	{
		@Override
		public void run()
		{
			ReloadData();
		}
	}
	
	private void ReloadData()
	{
		try (Connection con = DatabaseFactory.getConnection())
		{
			PreparedStatement statement = con.prepareStatement("SELECT char_name, pvpkills, online FROM characters ORDER BY pvpkills DESC, char_name ASC LIMIT 10");
			ResultSet result = statement.executeQuery();
			
			// refreshing top pvp list
			int i = 0; // index of array
			
			while (result.next())
			{
				topPvPList[i] = new PlayerInfo(i + 1, result.getString("char_name"), result.getInt("pvpkills"), 0, 0, result.getBoolean("online"));
				i++;
			}
			
			// refreshing top pk list
			statement = con.prepareStatement("SELECT char_name, pkkills, online FROM characters ORDER BY pkkills DESC, char_name ASC LIMIT 10");
			result = statement.executeQuery();
			
			i = 0; // index of array
			while (result.next())
			{
				topPkList[i] = new PlayerInfo(i + 1, result.getString("char_name"), 0, result.getInt("pkkills"), 0, result.getBoolean("online"));
				i++;
			}
			
			// refreshing top online list
			statement = con.prepareStatement("SELECT char_name, onlinetime, online FROM characters ORDER BY onlinetime DESC, char_name ASC LIMIT 10");
			result = statement.executeQuery();
			
			i = 0; // index of array
			while (result.next())
			{
				topOnlineList[i] = new PlayerInfo(i + 1, result.getString("char_name"), 0, 0, result.getInt("onlinetime"), result.getBoolean("online"));
				i++;
			}
			
			result.close();
			statement.close();
			
		}
		catch (SQLException e)
		{
			LOGGER.warning("ranking (status): could not load statistics informations" + e.getMessage());
		}
	}
	
	@Override
	public void onSpawn()
	{
		ReloadData();
	}
	
	@Override
	public void showChatWindow(PlayerInstance player)
	{
		GeneratePvPList(player);
	}
	
	@Override
	public void onBypassFeedback(PlayerInstance player, String command)
	{
		StringTokenizer st = new StringTokenizer(command, " ");
		String currentCommand = st.nextToken();
		
		if (currentCommand.startsWith("pvplist"))
		{
			GeneratePvPList(player);
		}
		
		else if (currentCommand.startsWith("pklist"))
		{
			GeneratePKList(player);
		}
		else if (currentCommand.startsWith("onlinelist"))
		{
			GenerateOnlineList(player);
		}
		
		super.onBypassFeedback(player, command);
	}
	
	private void GeneratePvPList(PlayerInstance p)
	{
		StringBuilder _PVPranking = new StringBuilder();
		for (PlayerInfo player : topPvPList)
		{
			if (player == null)
			{
				break;
			}
			
			_PVPranking.append("<table width=\"290\"><tr>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("<td FIXWIDTH=\"17\" align=\"center\">" + player.position + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"158\" align=\"center\">" + player.Nick + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"90\" align=\"center\">" + player.pvpCount + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"50\" align=\"center\">" + ((player.isOnline) ? "<font color=\"00FF00\">online</font>" : "<font color=\"CC0000\">offline</font>") + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("</tr></table>");
			_PVPranking.append("<img src=\"L2UI.Squaregray\" width=\"300\" height=\"1\">");
		}
		
		final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
		html.setFile(p, getHtmlPath(getId(), 0, p));
		html.replace("%objectId%", getObjectId());
		html.replace("%pvplist%", _PVPranking.toString());
		/* html.replace("%online%", String.valueOf(p.getUptime())); */
		p.sendPacket(html);
	}
	
	private void GeneratePKList(PlayerInstance p)
	{
		StringBuilder _PVPranking = new StringBuilder();
		for (PlayerInfo player : topPkList)
		{
			if (player == null)
			{
				break;
			}
			
			_PVPranking.append("<table width=\"290\"><tr>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("<td FIXWIDTH=\"17\" align=\"center\">" + player.position + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"158\" align=\"center\">" + player.Nick + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"90\" align=\"center\">" + player.pkCount + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"50\" align=\"center\">" + ((player.isOnline) ? "<font color=\"00FF00\">online</font>" : "<font color=\"CC0000\">offline</font>") + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("</tr></table>");
			_PVPranking.append("<img src=\"L2UI.Squaregray\" width=\"300\" height=\"1\">");
		}
		
		final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
		html.setFile(p, getHtmlPath(getId(), 2, p));
		html.replace("%objectId%", getObjectId());
		html.replace("%pklist%", _PVPranking.toString());
		p.sendPacket(html);
	}
	
	private void GenerateOnlineList(PlayerInstance p)
	{
		StringBuilder _PVPranking = new StringBuilder();
		for (PlayerInfo player : topOnlineList)
		{
			if (player == null)
			{
				break;
			}
			
			_PVPranking.append("<table width=\"290\"><tr>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("<td FIXWIDTH=\"17\" align=\"center\">" + player.position + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"158\" align=\"center\">" + player.Nick + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"90\" align=\"center\">" + ConverTime(player.onlineTime) + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"50\" align=\"center\">" + ((player.isOnline) ? "<font color=\"00FF00\">online</font>" : "<font color=\"CC0000\">offline</font>") + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("</tr></table>");
			_PVPranking.append("<img src=\"L2UI.Squaregray\" width=\"300\" height=\"1\">");
		}
		
		final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
		html.setFile(p, getHtmlPath(getId(), 3, p));
		html.replace("%objectId%", getObjectId());
		html.replace("%onlinelist%", _PVPranking.toString());
		p.sendPacket(html);
	}
	
	private String ConverTime(long seconds)
	{
		long remainder = seconds;
		int days = (int) remainder / (24 * 3600);
		remainder = remainder - (days * 3600 * 24);
		
		int hours = (int) (remainder / 3600);
		remainder = remainder - (hours * 3600);
		
		int minutes = (int) (remainder / 60);
		remainder = remainder - (hours * 60);
		
		seconds = remainder;
		
		String timeInText = "";
		
		if (days > 0)
		{
			timeInText = days + "<font color=\"LEVEL\">D</font> ";
		}
		if (hours > 0)
		{
			timeInText = timeInText + hours + "<font color=\"LEVEL\">H</font> ";
		}
		if (minutes > 0)
		{
			timeInText = timeInText + minutes + "<font color=\"LEVEL\">M</font>";
		}
		
		if (timeInText == "")
		{
			if (seconds > 0)
			{
				timeInText = seconds + "<font color=\"LEVEL\">S</font>";
			}
			else
			{
				timeInText = "N/A";
			}
		}
		return timeInText;
	}
	
	@Override
	public String getHtmlPath(int npcId, int val, PlayerInstance player)
	{
		String filename;
		
		if (val == 0)
		{
			filename = "data/html/Status/" + npcId + ".htm";
		}
		else
		{
			filename = "data/html/Status/" + npcId + "-" + val + ".htm";
		}
		
		if (HtmCache.getInstance().isLoadable(filename))
		{
			return filename;
		}
		
		return "data/html/Status/" + npcId + ".htm";
	}
	
}

 

 

found this somewhere in here so credits to that giy.

i just modified it to work on Mobius. 

create the Htmls, not hard.

my knowledge on coding is shit so plz dont judge.

at least it works fine with no errors.

 

this is for Classic IL. you dont need to change a lot of things to make it work for IL.

Edited by Drazeal

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

    • ⚔️ The Grand Opening Has Arrived! ⚔️ In just a few hours the gate to the eternal battlefield will be open and the war between Order and Chaos will be set once again ! Its time to claim your destiny 🔥 👉 Register now and join the fight today! 🌐 https://l2ovc.com
    • Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot! A great opportunity to invest in a stable digital asset at an early stage while the market is still forming. Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels! Low prices, multiple payment options, and other cool unique features! ⚡ Try it today — SOCNET STARS BOT ⚡ Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. ⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram. SMM Panel: Go – promote your social media accounts. We present to 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) in October! You can also use the promo code SOCNET (15% discount) for your first purchase. 2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support). 4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars 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
    • Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot! A great opportunity to invest in a stable digital asset at an early stage while the market is still forming. Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels! Low prices, multiple payment options, and other cool unique features! ⚡ Try it today — SOCNET STARS BOT ⚡ Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. ⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram. SMM Panel: Go – promote your social media accounts. We present to 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) in October! You can also use the promo code SOCNET (15% discount) for your first purchase. 2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support). 4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars 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
    • Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot! A great opportunity to invest in a stable digital asset at an early stage while the market is still forming. Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels! Low prices, multiple payment options, and other cool unique features! ⚡ Try it today — SOCNET STARS BOT ⚡ Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. ⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram. SMM Panel: Go – promote your social media accounts. We present to 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) in October! You can also use the promo code SOCNET (15% discount) for your first purchase. 2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template: "SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread! 3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support). 4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars 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