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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • WTS Adenas per million or quantity.  Price: 7u$d x 1kk (best price in quantity).   💸  STOCK : 14kk Acc: 🔸 Tyrant Lv. 51 w/o equipment, PA to 03/11/2025. Dye +4STR-4CON.             (i transfer to your acc). Price: 100 u$d 🔹Prophet Lv. 46 full buff, Karmian Set + joyas D.             (mail clean).Price: 150 u$d Discord: dcr32 - Zeep#0215 Telegram: @xDCr32
    • 📢 It’s Time! I was thinking… when will be the perfect time? The answer is now — no more waiting. ⏳ 3 years without L2Mid… Now we are coming strong 💪 and motivated to play again — an Interlude server ⚔️ like old school before. Here, there were good times… and now, they return. 🏆 Announcing: L2Mid New Server – x25 One of the best Lineage II experiences since 2011 is making its return. ✨ Grand Opening: 10 October 2025 🛠 Open Beta Test: 22 September – 9 October 2025 🔥 Get ready for an epic journey, fierce battles, and the community you’ve been waiting for. 💥 Let’s make history again!  
    • Stop wasting time checking if your players are live Stream Monitor does it for you, fully automatically.   ✅ Supports Twitch, Trovo, YouTube, Kick, TikTok (Facebook coming soon) ✅ Compatible with L2OFF servers via ODBC 18 (SQL Server) ✅ Automatically gives in-game rewards when streamers are live ✅ Option to give rewards manually if desired ✅ Keeps complete logs of all checks/delivery ✅ Reload configuration without restarting ✅ Windows-ready (fully tested) 📦 Available Options: 30-day license key – €50 Full source code – €400 💡 Ideal For: L2OFF server owners who want to reward active streamers automatically L2J support (coming soon) 📜 Easy Setup: Add your streamers & rewards in config.ini Run the app Sit back and enjoy hands-free streamer rewards   🚀 Coming Soon: You will soon see Stream Monitor running on L2Mid server! more updates coming soon.   discord: l2mid.com       [GENERAL] check_interval_hours = 2 [PLATFORMS] trovo = true twitch = true youtube = true tiktok = true kick = true [TWITCH] client_id = client_secret = [YOUTUBE] api_key = [DATABASE] sql_server = 127.0.0.1 database = lin2world username = sa password = 123123^&$ log_file = delivery.log [ITEMS] item1 = {"item_id": 57, "amount": 1000} item2 = {"item_id": 57, "amount": 5} item3 = {"item_id": 57, "amount": 9999} [STREAMERS_TROVO] 1 = {"username": "_BINTIK_BINTIK", "nick": "devgold"} 2 = {"username": "435tsdf", "nick": "devgold"} [STREAMERS_TWITCH] 1 = {"username": "ninja", "nick": "devgold"} [STREAMERS_YOUTUBE] 1 = {"username": "gilvandark666", "nick": "devgold"} [STREAMERS_TIKTOK] 1 = {"username": "1st.tresh", "nick": "devgold"} [STREAMERS_KICK] 1 = {"username": "serenaparis", "nick": "devgold"}  
  • 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