I'm having some trouble inserting a new table into the db. I'm using Navicat to import an .sql script and its not liking the ENGINE = MyISAM DEFAULT CHARSET=latin1; line.
MySQL Version: 5.1.41
So I tried manually entering the table with the int(10) field and the two varchar(45) fields, but when I run the gameserver, I'm getting errors for the color field, like 3399FF, it's not liking the FF.#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO pvp_nick_color VALUES --' at line 5
How would I go about fixing this and making the table correctly...
FYI: I know this script is for Epilogue, but I'm using it for Gracia Final (I changed all the imports) If this matters at all.
Credits to B1gBoss:
http://www.maxcheaters.com/forum/index. ... c=114859.0
Code: Select all
Index: java/com/l2jserver/gameserver/GameServer.java===================================================================--- java/com/l2jserver/gameserver/GameServer.java (revision 3803)+++ java/com/l2jserver/gameserver/GameServer.java (working copy)@@ -109,6 +109,7 @@ import com.l2jserver.gameserver.model.L2Manor; import com.l2jserver.gameserver.model.L2Multisell; import com.l2jserver.gameserver.model.L2World;+import com.l2jserver.gameserver.model.base.ColorNameEngine; import com.l2jserver.gameserver.model.entity.Hero; import com.l2jserver.gameserver.model.entity.TvTManager; import com.l2jserver.gameserver.model.olympiad.Olympiad;@@ -298,6 +299,8 @@ TransformationManager.getInstance(); AirShipManager.getInstance(); + ColorNameEngine.load();+ try { _log.info("Loading Server Scripts");Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java===================================================================--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 3803)+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)@@ -132,6 +132,7 @@ import com.l2jserver.gameserver.model.actor.status.PcStatus; import com.l2jserver.gameserver.model.base.ClassId; import com.l2jserver.gameserver.model.base.ClassLevel;+import com.l2jserver.gameserver.model.base.ColorNameEngine; import com.l2jserver.gameserver.model.base.Experience; import com.l2jserver.gameserver.model.base.PlayerClass; import com.l2jserver.gameserver.model.base.Race;@@ -4494,6 +4495,12 @@ */ public final void broadcastUserInfo() {+ if(getPvpKills() > 0) {+ getAppearance().setNameColor(Integer.decode("0x" + ColorNameEngine.getColor(getPvpKills(), ColorNameEngine.Type.PVP)));+ }+ if(getPkKills() > 0) {+ getAppearance().setTitleColor(Integer.decode("0x" + ColorNameEngine.getColor(getPkKills(), ColorNameEngine.Type.PK)));+ } // Send a Server->Client packet UserInfo to this L2PcInstance sendPacket(new UserInfo(this)); @@ -4501,6 +4508,7 @@ if (Config.DEBUG) _log.fine("players to notify:" + getKnownList().getKnownPlayers().size() + " packet: [S] 03 CharInfo"); + broadcastPacket(new CharInfo(this)); broadcastPacket(new ExBrExtraUserInfo(this)); }Index: java/com/l2jserver/gameserver/model/base/ColorNameEngine.java===================================================================--- java/com/l2jserver/gameserver/model/base/ColorNameEngine.java (revision 0)+++ java/com/l2jserver/gameserver/model/base/ColorNameEngine.java (revision 0)@@ -0,0 +1,184 @@+/*+ * 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.base;++import java.sql.Connection;+import java.sql.PreparedStatement;+import java.sql.ResultSet;+import java.sql.SQLException;+import java.util.List;+import java.util.logging.Logger;++import javolution.util.FastList;+import javolution.util.FastMap;++import com.l2jserver.L2DatabaseFactory;++/**+ * @author BiggBoss+ */+public class ColorNameEngine {+ + /* Info logger */+ private static Logger _log = Logger.getLogger(ColorNameEngine.class.getName());+ /* FastMaps to hold the data (Needed Count, Color range) */+ private static FastMap<Integer, Integer> _pvpColors = new FastMap<Integer, Integer>();+ private static FastMap<Integer, Integer> _pkColors = new FastMap<Integer, Integer>();+ /* Enum to reduce the needed methods */+ public static enum Type {+ PVP,+ PK+ }+ /* Enum to search the avobe and the below ranges in the lists */+ public static enum Location {+ AVOBE,+ BELOW+ }+ //No instances for this class!+ private ColorNameEngine() {++ }+ + /**+ * Load the necessary info from database at server start up+ */+ public static void load() {+ try {+ Connection con = L2DatabaseFactory.getInstance().getConnection();+ PreparedStatement pvpStatement = con.prepareStatement("SELECT * FROM pvp_nick_color WHERE type = ?");+ pvpStatement.setString(1, "pvp");+ + ResultSet pvpSet = pvpStatement.executeQuery();+ while(pvpSet.next()) {+ _pvpColors.put(pvpSet.getInt("pvp_count_needed"), Integer.valueOf(pvpSet.getString("color")));+ }+ _log.info("Loaded " + _pvpColors.keySet().size() + " pvp color templates.");+ pvpStatement.close();+ pvpSet.close();+ + PreparedStatement pkStatement = con.prepareStatement("SELECT * FROM pvp_nick_color WHERE type = ?");+ pkStatement.setString(1, "pk");+ + ResultSet pkSet = pkStatement.executeQuery();+ while(pkSet.next()) {+ _pkColors.put(pkSet.getInt("pvp_count_needed"), Integer.valueOf(pkSet.getString("color")));+ }+ _log.info("Loaded " + _pkColors.keySet().size() + " pk color templates.");+ + pkStatement.close();+ pkSet.close();+ con.close();+ }+ catch(SQLException sqle) {+ _log.warning("Problems during initialization:\n" + sqle);+ }+ }+ + /**+ * Returns an int which represents the color name+ * @param pvpCount+ * @return the color name+ */+ public static int getColor(Integer pvpCount, Type type) {+ int pvps = 0;+ List<Integer> list = new FastList<Integer>();+ + if(type == Type.PVP)+ list.addAll(_pvpColors.keySet());+ else+ list.addAll(_pkColors.keySet());+ + for(int i : list) {+ //Current pvp/pk count < min pvp/pk range = nothing+ if(pvpCount < get(list, Location.BELOW)) {+ pvps = Integer.decode("FFFFFF");+ break;+ }+ else {+ if(pvpCount < i && pvpCount > getNext(i, list, Location.BELOW)) {+ if(type == Type.PVP)+ pvps = _pvpColors.get(i);+ else+ pvps = _pkColors.get(i);+ break;+ }+ else {+ continue;+ }+ }+ }+ return pvps;+ }+ + private static int get(List<Integer> list, Location location) {+ int counter = 0;+ + if(location.equals(Location.AVOBE)) {+ for(int i : list) {+ if(counter > i)+ counter = i;+ else+ continue;+ }+ }+ else {+ for(int i : list) {+ if(counter < i)+ counter = i;+ else+ continue;+ }+ }+ + + return counter;+ }+ + /**+ * Protection against careless admins who enter the ranges in+ * a mess order+ * @param number+ * @param list+ * @param location+ * @return the next higher or smaller number of the list+ */+ private static int getNext(int number, List<Integer> list, Location location) {+ int retorned = 0;+ int counter = get(list, Location.AVOBE);+ + if(location.equals(Location.AVOBE)) {+ for(int i : list) {+ + if(i > number && (i - number) < counter) {+ counter = i - number;+ retorned = i;+ }+ else+ continue;+ }+ }+ else {+ for(int i : list) {+ if(i < number && number - i < counter) {+ counter = number - i;+ retorned = i;+ }+ else+ continue;+ }+ }+ return retorned;+ }+}\ No newline at end of fileIndex: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java===================================================================--- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (revision 3803)+++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (working copy)@@ -47,6 +47,7 @@ import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.instance.L2ClassMasterInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;+import com.l2jserver.gameserver.model.base.ColorNameEngine; import com.l2jserver.gameserver.model.entity.ClanHall; import com.l2jserver.gameserver.model.entity.Couple; import com.l2jserver.gameserver.model.entity.Fort;@@ -187,6 +188,13 @@ else GmListTable.getInstance().addGm(activeChar, true); }+ + if(activeChar.getPvpKills() > 0) {+ activeChar.getAppearance().setNameColor(Integer.decode("0x" + ColorNameEngine.getColor(activeChar.getPvpKills(), ColorNameEngine.Type.PVP)));+ }+ if(activeChar.getPkKills() > 0) {+ activeChar.getAppearance().setTitleColor(Integer.decode("0x" + ColorNameEngine.getColor(activeChar.getPkKills(), ColorNameEngine.Type.PK)));+ } // Set dead status if applies if (activeChar.getCurrentHp() < 0.5)
Code: Select all
CREATE TABLE IF NOT EXISTS `pvp_nick_color` ( `pvp_count_needed` int(10) DEFAULT NULL, `color` varchar(45) DEFAULT NULL, `type` varchar(45) DEFAULT NULL,) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO pvp_nick_color VALUES-- Pvp(50, '3399FF', 'pvp'),(100, '003366', 'pvp'),(150, '009900', 'pvp'),(200, 'FF00FF', 'pvp'),(250, 'FF9933', 'pvp'),(500, '999966', 'pvp'),(1000, '333333', 'pvp');-- Pk(50, 'FF6633', 'pk'),(100, 'FF3300', 'pk'),(150, 'FF9999', 'pk'),(200, 'FF6666', 'pk'),(250, 'FF3333', 'pk'),(500, 'CC0000', 'pk'),(1000, 'FF0000', 'pk');
When I run the gameserver, I'm getting the NumberFormatException: For (3399FF) errors
Something wrong with the SQL table...I believe...
Thanks!