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`),
Where was I called a scammer? Is there any proof, etc.? There are a lot of reviews about our store online, etc.
https://zhyk.org/forum/showthread.php?t=1108673
🔍 Inventory 1.0 is a next-generation inventory system that stands out with its special minimal clothing system. Carefully designed and prepared according to the highest standards of your server, it not only enhances your gaming experience but also contributes to your server's infrastructure.
⚙️ Supported: QB-CORE
Features:
✅ Instant Delivery: All products you purchase will be instantly assigned to your account as soon as your payment is completed.
✅ Clothing System: With the special animated clothing configurations in your inventory, you will be able to change outfits with ease. Experience a unique roleplaying experience with high-quality animations and customizable clothing options.
✅ Minimalist Inventory System: This inventory system, with its visuals, animations, and mechanics, offers maximum efficiency without overwhelming your screen and limiting your roleplaying experience. It’s designed to be user-friendly while enhancing your roleplaying experience.
✅ Continuous Updates: The content in the inventory is regularly updated with innovative features added. New animations, additional clothing options, and cutting-edge features ensure a fresh and dynamic experience.
✅ Easy Setup and Compatibility: Compatible with QB-CORE, this system is easy to install and optimized for quick integration into your server. It works seamlessly with a simple drag-and-drop method.
✅ Performance Optimization: The system is optimized to avoid low FPS and performance drops. All features of the inventory run smoothly without affecting your server’s performance.
✅ Multilingual Support: With support for different languages, you can cater to an international player base and build a larger community on your server.
✅ Flexible Customization Options: You can fully customize the inventory according to your needs and server rules. Choose between different outfits and animations to create a unique gaming experience.
✅ Comprehensive Help and Support: With 24/7 support, you can quickly resolve any issues you encounter. Our technical support and user guides are always here to assist you.
Shop Now! Take your game to the next level with Inventory 1.0 and enjoy its unique features. Get ready to make a real difference in your roleplaying experience!
--------------------------TEBEX: https://matza.tebex.io/package/7174862 --------------------------
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
### 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`),thank you very much
4 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now