I talk to the npc -> click on "Visualizar" shows the list of characters correctly.
but when I close the window and open it again and talk to the npc -> click on "Visualizar" again doubles the list of characters and every time I do that increases the list of the same characters every 10 results
you can help me fix it? or better?
problem at L2TopDeathManagerInstance.java
FullPatch
### Eclipse Workspace Patch 1.0
#P L2J_LastShadowServer
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 5722)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -320,9 +325,9 @@
private static final String DELETE_ITEM_REUSE_SAVE = "DELETE FROM character_item_reuse_save WHERE charId=?";
// Character Character SQL String Definitions:
- private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createDate) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=? WHERE charId=?";
- private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createDate,language FROM characters WHERE charId=?";
+ private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createDate,deaths) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,deaths=? WHERE charId=?";
+ private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createDate,language,deaths FROM characters WHERE charId=?";
// Character Teleport Bookmark:
private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)";
@@ -541,6 +546,14 @@
private int _duelId = 0;
private SystemMessageId _noDuelReason = SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL;
+ /** Numero de pjs muertos en pvp suma una muerte */
+ private int _deaths;
+
/** Boat and AirShip */
private L2Vehicle _vehicle = null;
private Point3D _inVehiclePosition;
@@ -2751,6 +2767,23 @@
}
/**
+ * @return Las muertes que L2PcInstance recoje.
+ */
+ public int getDeaths()
+ {
+ return _deaths;
+ }
+
+ /**
+ * Setea las deaths en L2PcInstance durante el pvp flag.
+ * @param deaths
+ */
+ public void setDeaths(int deaths)
+ {
+ _deaths = deaths;
+ }
+
+ /**
* @return the Fame of this L2PcInstance
*/
public int getFame()
@@ -6188,6 +6236,7 @@
))
{
increasePvpKills(target);
+ increaseDeaths(target);
}
else
// Target player doesn't have pvp flag set
@@ -6197,6 +6246,7 @@
{
// 'Both way war' -> 'PvP Kill'
increasePvpKills(target);
+ increaseDeaths(target);
return;
}
@@ -6235,6 +6289,23 @@
}
/**
+ * Incrementa las muertes y envia informacion al personaje
+ * @param target
+ */
+ public void increaseDeaths(L2Character target)
+ {
+ if (!(target instanceof L2PcInstance) && AntiFeedManager.getInstance().check(this, target))
+ {
+ // incrementa Deaths cuando el pj es matado en PvPMode
+ setDeaths(getDeaths() + 1);
+
+ // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
+ sendPacket(new UserInfo(this));
+ sendPacket(new ExBrExtraUserInfo(this));
+ }
+ }
+
+ /**
* Increase pk count, karma and send the info to the player
* @param target
*/
@@ -7679,6 +7750,7 @@
statement.setInt(35, isNoble() ? 1 : 0);
statement.setLong(36, 0);
statement.setDate(37, new Date(getCreateDate().getTimeInMillis()));
+ statement.setInt(38, getDeaths());
statement.executeUpdate();
}
catch (Exception e)
@@ -7873,6 +7945,9 @@
// Language
player.setLang(rset.getString("language"));
+ // Setea deaths No necesita restaurar
+ player.setDeaths(rset.getInt("deaths"));
+
// Retrieve the name and ID of the other characters assigned to this account.
try (PreparedStatement stmt = con.prepareStatement("SELECT charId, char_name FROM characters WHERE account_name=? AND charId<>?"))
{
@@ -8316,7 +8391,8 @@
statement.setInt(50, getBookMarkSlot());
statement.setInt(51, getVitalityPoints());
statement.setString(52, getLang());
- statement.setInt(53, getObjectId());
+ statement.setInt(53, getDeaths());
+ statement.setInt(54, getObjectId());
statement.execute();
statement.close();
\ No newline at end of file
Index: java/com/l2jserver/gameserver/model/actor/instance/L2TopDeathManagerInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2TopDeathManagerInstance.java (revision 0)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2TopDeathManagerInstance.java (working copy)
@@ -0,0 +1,181 @@
+/*
+ * 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 com.l2jserver.gameserver.model.actor.instance;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import javolution.text.TextBuilder;
+
+import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * @author DLjac
+ */
+
+public class L2TopDeathManagerInstance extends L2NpcInstance
+{
+ public String filename;
+
+ public L2TopDeathManagerInstance(int objectId, L2NpcTemplate template)
+ {
+ super(objectId, template);
+ }
+
+ @Override
+ public void onBypassFeedback(L2PcInstance player, String command)
+ {
+ if ((player == null) || (player.getLastFolkNPC() == null) || (player.getLastFolkNPC().getObjectId() != this.getObjectId()))
+ {
+ return;
+ }
+
+ if (command.startsWith("TopDeaths"))
+ {
+ TopDeaths(player);
+ }
+ }
+
+ @Override
+ public void showChatWindow(L2PcInstance player, int val)
+ {
+ filename = (getHtmlPath(getNpcId(), val));
+ NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
+ msg.setHtml(TopWindow(player));
+ msg.replace("%objectId%", String.valueOf(this.getObjectId()));
+ player.sendPacket(msg);
+ }
+
+ private String TopWindow(L2PcInstance player)
+ {
+ TextBuilder tb = new TextBuilder();
+ tb.append("<html><title>Ranking Basado en K/D</title><body>");
+ tb.append("<center>");
+ tb.append("<img src=\"l2ui_ch3.herotower_deco\" width=\"256\" height=\"32\"><tr>");
+ tb.append("<font color=\"999999\">Top 10 Kills/Deaths</font><br><br>");
+ tb.append("Hola! " + player.getName() + "<br>");
+ tb.append("<br>");
+ tb.append("<br>");
+ tb.append("<tr>");
+ tb.append("<td><button value=\"Visualizar\" action=\"bypass -h npc_%objectId%_TopDeaths\" width=\"100\" height=\"21\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></tr>");
+ tb.append("</tr>");
+ tb.append("<img src=\"l2ui_ch3.herotower_deco\" width=\"256\" height=\"32\"><br>");
+ tb.append("</center>");
+ tb.append("</body></html>");
+ return tb.toString();
+ }
+
+ private int pos;
+ private final TextBuilder _deathsList = new TextBuilder();
+
+ @SuppressWarnings("null")
+ private void TopDeaths(L2PcInstance player)
+ {
+ Connection con = null;
+
+ try
+ {
+ pos = 1;
+ con = L2DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("SELECT char_name,pvpkills,deaths FROM characters WHERE accesslevel=0 ORDER BY deaths LIMIT 10");
+
+ ResultSet result = statement.executeQuery();
+
+ while (result.next())
+ {
+ addChar(pos, result.getString("char_name"), result.getInt("pvpkills"), result.getInt("deaths"));
+ pos++;
+
+ NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
+ TextBuilder sb = new TextBuilder();
+ sb.append("<html><title>Ranking Basado en K/D</title><body>");
+ sb.append("<center>");
+ sb.append("<img src=\"l2ui_ch3.herotower_deco\" width=256 height=32><br>");
+ sb.append("<font color=\"999999\">Top 10 Kills/Deaths</font><br><br>");
+ sb.append("<br>");
+ sb.append("<table border=0 width=250><tr>");
+ sb.append("<td FIXWIDTH=25 height=24 align=\"center\"><font color=\"ff0000\">No.</font></td>");
+ sb.append("<td FIXWIDTH=80 height=24 align=\"center\"><font color=\"ae9977\">Nombre</font></td>");
+ sb.append("<td FIXWIDTH=50 height=24 align=\"center\"><font color=\"ae9977\">Kills</font></td>");
+ sb.append("<td FIXWIDTH=50 height=24 align=\"center\"><font color=\"ae9977\">Deaths</font></td>");
+ sb.append("<td FIXWIDTH=60 height=24 align=\"center\"><font color=\"ea8b11\">K/D Ratio</font></td></tr></table>");
+ sb.append(loadDeathList());
+ sb.append("<img src=\"l2ui_ch3.herotower_deco\" width=256 height=32><br>");
+ sb.append("</center>");
+ sb.append("</body></html>");
+ html.setHtml(sb.toString());
+ player.sendPacket(html);
+ }
+
+ result.close();
+ statement.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ try
+ {
+ con.close();
+ }
+ catch (Exception e)
+ {
+
+ }
+ }
+ }
+
+ public String loadDeathList()
+ {
+ return _deathsList.toString();
+ }
+
+ /**
+ * @param pos
+ * @param name
+ * @param pvp
+ * @param muertes
+ */
+ private void addChar(int pos, String name, int pvp, int muertes)
+ {
+ float ratecalc = (float) pvp / (float) muertes;
+ _deathsList.append("<table border=0 width=250><tr>");
+ _deathsList.append("<td FIXWIDTH=25 align=\"center\">" + pos + ".</td>");
+ _deathsList.append("<td FIXWIDTH=80 align=\"center\">" + name + "</td>");
+ _deathsList.append("<td FIXWIDTH=50 align=\"center\">" + pvp + "</td>");
+ _deathsList.append("<td FIXWIDTH=50 align=\"center\">" + muertes + "</td>");
+ _deathsList.append("<td FIXWIDTH=60 align=\"center\"><font color=FF0000>" + ratecalc + "</font></td></tr></table>");
+ }
+ }
+}
\ No newline at end of file
DataPack ->characters.sql
`language` varchar(2) DEFAULT NULL,
+ `deaths` decimal(11,0) DEFAULT NULL,
PRIMARY KEY (`charId`),
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.
DISCORD :
utchiha_market
telegram :
https://t.me/utchiha_market
SELLIX STORE :
https://utchihamkt.mysellix.io/
Join our server for more products :
https://discord.gg/hood-services
https://campsite.bio/utchihaamkt
Xmas Wolf Chariot Mount | Lineage 2 Mod
Celebrate the holiday spirit in Lineage 2 with this festive Xmas Wolf Chariot Mount! Created for protocol 166, this unique modification features majestic wolf mounts with holiday-themed harnesses pulling a decorative chariot.
If you have questions or want to add this updated skill to your game, feel free to contact me via Skype or Discord.
Download or in Discord Client Dev channel https://discord.gg/XdCb9dmTtf
06/12/2024 21:00 GMT +2
High Five - PvP server x45 - Aria Victoria Style 2004
NPC Buffer & Enchanted NPC Buffer.
Global Gatekeeper.
Clan Hall Teleports & Clan GM Shop (-20%).
Offline Shop.
GM shop up to B Grade.
Auto Farm system.
TvT - CTF - DM - Party Farm - Event Boss
Craftable Hero Weapon.
Instances Solo and Party, weekly and daily.
No kamael.
More informations can be found on our website including a "how to connect" greek guide
Valkyria is based on aCis
https://l2valkyria.com
Question
StarSCreams
Freya HighFive 5 BETA
hello, could you help me with this code?
I talk to the npc -> click on "Visualizar" shows the list of characters correctly.
but when I close the window and open it again and talk to the npc -> click on "Visualizar" again doubles the list of characters and every time I do that increases the list of the same characters every 10 results
you can help me fix it? or better?
problem at L2TopDeathManagerInstance.java
FullPatch
thank you very much
4 answers to this question
Recommended Posts
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.