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.

×
×
  • Create New...