dymek1984 Posted August 1, 2012 Posted August 1, 2012 Hello! Trying to make scrypt to change the nickname prefix by pvp count But have little problem with that. exactly: here is the diff Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 5538) +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy) @@ -4343,7 +4343,58 @@ DuelManager.getInstance().broadcastToOppositTeam(this, update); } } - + + public void updatePrefix(int pvpKills) + { + if (Config.PVP_PREFIX_SYSTEM_ENABLED) + { + //Check if the character has GM access + if (isGM()) + return; + { + if ((pvpKills >= (Config.PVP_LVL1)) && (pvpKills <= (Config.PVP_LVL1))) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL1 + getActingPlayer().getName()); + } + else if ((pvpKills >= (Config.PVP_LVL2)) && (pvpKills <= (Config.PVP_LVL2))) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL2 + getActingPlayer().getName()); + } + else if ((pvpKills >= (Config.PVP_LVL3)) && (pvpKills <= (Config.PVP_LVL3))) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL3 + getActingPlayer().getName()); + } + else if ((pvpKills >= (Config.PVP_LVL4)) && (pvpKills <= (Config.PVP_LVL4))) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL4 + getActingPlayer().getName()); + } + else if ((pvpKills >= (Config.PVP_LVL5)) && (pvpKills <= (Config.PVP_LVL5))) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL5 + getActingPlayer().getName()); + } + else if ((pvpKills >= (Config.PVP_LVL6)) && (pvpKills <= (Config.PVP_LVL6))) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL6 + getActingPlayer().getName()); + } + else if ((pvpKills >= (Config.PVP_LVL7)) && (pvpKills <= (Config.PVP_LVL7))) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL7 + getActingPlayer().getName()); + } + else if ((pvpKills >= (Config.PVP_LVL8)) && (pvpKills <= (Config.PVP_LVL8))) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL8 + getActingPlayer().getName()); + } + else if ((pvpKills >= (Config.PVP_LVL9)) && (pvpKills <= (Config.PVP_LVL9))) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL9 + getActingPlayer().getName()); + } + else if (pvpKills >= (Config.PVP_LVL10)) + { + getActingPlayer().setName(Config.NAME_PREFIX_FOR_PVP_LVL10 + getActingPlayer().getName()); + } + } + } + } /** * Send a Server->Client packet UserInfo to this L2PcInstance and CharInfo to all L2PcInstance in its _KnownPlayers.<BR><BR> * @@ -5684,6 +5735,9 @@ // Add karma to attacker and increase its PK counter setPvpKills(getPvpKills() + 1); + updatePrefix(getPvpKills()); + broadcastUserInfo(); + // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter sendPacket(new UserInfo(this)); sendPacket(new ExBrExtraUserInfo(this)); Index: java/com/l2jserver/Config.java =================================================================== --- java/com/l2jserver/Config.java (revision 5538) +++ java/com/l2jserver/Config.java (working copy) @@ -725,6 +725,27 @@ public static int L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP; public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP; public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST; + public static boolean PVP_PREFIX_SYSTEM_ENABLED; + public static int PVP_LVL1; + public static int PVP_LVL2; + public static int PVP_LVL3; + public static int PVP_LVL4; + public static int PVP_LVL5; + public static int PVP_LVL6; + public static int PVP_LVL7; + public static int PVP_LVL8; + public static int PVP_LVL9; + public static int PVP_LVL10; + public static String NAME_PREFIX_FOR_PVP_LVL1; + public static String NAME_PREFIX_FOR_PVP_LVL2; + public static String NAME_PREFIX_FOR_PVP_LVL3; + public static String NAME_PREFIX_FOR_PVP_LVL4; + public static String NAME_PREFIX_FOR_PVP_LVL5; + public static String NAME_PREFIX_FOR_PVP_LVL6; + public static String NAME_PREFIX_FOR_PVP_LVL7; + public static String NAME_PREFIX_FOR_PVP_LVL8; + public static String NAME_PREFIX_FOR_PVP_LVL9; + public static String NAME_PREFIX_FOR_PVP_LVL10; //-------------------------------------------------- // NPC Settings @@ -2421,7 +2442,29 @@ } } } - + // PVP Name Prefix System configs - Start + PVP_PREFIX_SYSTEM_ENABLED = Boolean.parseBoolean(L2JModSettings.getProperty("EnablePrefixSystem", "false")); + PVP_LVL1 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl1", "500")); + PVP_LVL2 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl2", "1000")); + PVP_LVL3 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl3", "2000")); + PVP_LVL4 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl4", "2500")); + PVP_LVL5 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl5", "3000")); + PVP_LVL6 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl6", "350")); + PVP_LVL7 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl7", "4000")); + PVP_LVL8 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl8", "4500")); + PVP_LVL9 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl9", "5000")); + PVP_LVL10 = Integer.parseInt(L2JModSettings.getProperty("PvpLvl10", "7000")); + NAME_PREFIX_FOR_PVP_LVL1 = L2JModSettings.getProperty("PrefLvl1", "[Cadet]"); + NAME_PREFIX_FOR_PVP_LVL2 = L2JModSettings.getProperty("PrefLvl2", "[slayer]"); + NAME_PREFIX_FOR_PVP_LVL3 = L2JModSettings.getProperty("PrefLvl3", "[Corporal]"); + NAME_PREFIX_FOR_PVP_LVL4 = L2JModSettings.getProperty("PrefLvl4", "[Killer]"); + NAME_PREFIX_FOR_PVP_LVL5 = L2JModSettings.getProperty("PrefLvl5", "[Executioner]"); + NAME_PREFIX_FOR_PVP_LVL6 = L2JModSettings.getProperty("PrefLvl6", "[Most Wanted]"); + NAME_PREFIX_FOR_PVP_LVL7 = L2JModSettings.getProperty("PrefLvl7", "[Enforcer}"); + NAME_PREFIX_FOR_PVP_LVL8 = L2JModSettings.getProperty("PrefLvl8", "[Assasin}"); + NAME_PREFIX_FOR_PVP_LVL9 = L2JModSettings.getProperty("PrefLvl9", "[Exterminator]"); + NAME_PREFIX_FOR_PVP_LVL10 = L2JModSettings.getProperty("PrefLvl10", "[Lord of War]"); + // PvP Name Prefix System configs - End BANKING_SYSTEM_ENABLED = Boolean.parseBoolean(L2JModSettings.getProperty("BankingEnabled", "false")); BANKING_SYSTEM_GOLDBARS = Integer.parseInt(L2JModSettings.getProperty("BankingGoldbarCount", "1")); BANKING_SYSTEM_ADENA = Integer.parseInt(L2JModSettings.getProperty("BankingAdenaCount", "500000000")); Problem is: when the player has 500 pvp automatically appear prefix [cadet] but as I will have more pvp it appears [slayer] and nick looks like "[slayer][cadet]Nickname" jak zrobic aby usunac poprzedni prefix i dodac nowy? and code is written correctly? Quote
0 Tryskell Posted August 1, 2012 Posted August 1, 2012 First, "getActingPlayer()." isn't needed at all if your code is in L2PcInstance. That will cut 1/3 of code, make the crap easier to read and make it slighty faster aswell. Second, you're adding prefix to name. When you change of name, you're doing the same again. Which mean : "blabla1" + "blabla2" = "blabla1blabla2" "blabla3" + "blabla1blabla2" = "blabla3blabla1blabla2" (prefix + current name) The code is ok and it makes what you said, that's how you think your code which is wrong. You mustn't use getName, but something new as getOriginalName(). I must say, editing the name like you do is really fucking up, as depending of the pack the name can be entire part of identification process (such as online feature, friendlist, and such). If your pack doesn't follow behind, you will have funny bugs. Quote
0 dymek1984 Posted August 1, 2012 Author Posted August 1, 2012 Tryskell You're right, better not to change the nickname of players, but it is a good idea. This may add a new column in characters sql "prefix" and insert in front of Nick. If it can be to do so, Quote
0 vampir Posted August 1, 2012 Posted August 1, 2012 You dont need to add anything into database.. apply this patch: http://pastebin.com/HwkjLbvQ run updatePrefix in restore method, and also go to UserInfo and replace: _name = player.getName(); with _name = player.getPrefix()+player.getName(); Quote
0 Joκκєrino Posted August 1, 2012 Posted August 1, 2012 You should make a column named "Prefix" into characters table . Every "x" PVP , this gonna change to ... Quote
0 vampir Posted August 1, 2012 Posted August 1, 2012 You should make a column named "Prefix" into characters table . Every "x" PVP , this gonna change to ... no, this will just create unnecessary column, if updatePrefix will be run every time u log in, and every time u are getting pvp, u dont need to add anything else. Quote
0 Joκκєrino Posted August 1, 2012 Posted August 1, 2012 no, this will just create unnecessary column, if updatePrefix will be run every time u log in, and every time u are getting pvp, u dont need to add anything else. Your words are full of truth , but i just exemplified another method . Quote
0 ^Wyatt Posted August 1, 2012 Posted August 1, 2012 Really I think the best and cleanest way is what jokkerino said. 1-Create a column to put there all prefix, to not mess it with nicks. 2-Find the code where you write the nick to be visual-shown, and add there the prefix. Coz if u simply do it with setName()... You'll get full of bugs with other mods, as Tryskell said. Quote
0 vampir Posted August 1, 2012 Posted August 1, 2012 Really I think the best and cleanest way is what jokkerino said. 1-Create a column to put there all prefix, to not mess it with nicks. 2-Find the code where you write the nick to be visual-shown, and add there the prefix. Coz if u simply do it with setName()... You'll get full of bugs with other mods, as Tryskell said. thats what i wrote in the patch, i just think creating new column for such thing is useless, we could make database table for everything.. Quote
0 Joκκєrino Posted August 2, 2012 Posted August 2, 2012 thats what i wrote in the patch, i just thing creating new column for such thing is useless, we could make database table for everything.. Quality > Quantity . Quote
0 ^Wyatt Posted August 2, 2012 Posted August 2, 2012 @vampir Sry, I didn't see any patch. This mobile is like a peace of shit xd Quote
0 dymek1984 Posted August 2, 2012 Author Posted August 2, 2012 have not found in UserInfo "_name = player.getName();" Quote
0 vampir Posted August 2, 2012 Posted August 2, 2012 have not found in UserInfo "_name = player.getName();" sorry, didnt look how it is made in l2jserver change line: writeS(_activeChar.getName()); with writeS(_activeChar.getPrefix+_activeChar.getName()); Quote
0 dymek1984 Posted August 2, 2012 Author Posted August 2, 2012 I did as you said. 1st error - log in and see before Nick null, but only for me, others I can see normally 2nd error - prefix disappears after logoff 3rd now I think of it, however, is not a good idea, btw thx for help. Quote
0 vampir Posted August 2, 2012 Posted August 2, 2012 1st, change private String _prefix; to private String _prefix = ""; 2st, u didnt add this method in restore method in L2PcInstance 3rd, no problem, want me to lock it? Quote
Question
dymek1984
Hello!
Trying to make scrypt to change the nickname prefix by pvp count
But have little problem with that.
exactly: here is the diff
Problem is: when the player has 500 pvp automatically appear prefix [cadet]
but as I will have more pvp it appears [slayer] and nick looks like "[slayer][cadet]Nickname"
jak zrobic aby usunac poprzedni prefix i dodac nowy?
and code is written correctly?
14 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.