Jump to content
  • 0

[Help] Prefix name change by pvp count


Question

Posted

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?

14 answers to this question

Recommended Posts

  • 0
Posted

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.

  • 0
Posted

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,

  • 0
Posted

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();

  • 0
Posted

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.

  • 0
Posted

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 .

  • 0
Posted

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.

  • 0
Posted

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..

  • 0
Posted

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());

  • 0
Posted

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.

  • 0
Posted

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?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • LIVE VERIFICATION? SUMSUB? “IMPOSSIBLE”? ▪ Spoiler: it is possible — if you know who to work with. A client came in with a task to pass **live verification** on **WantToPay**, a Telegram virtual card service. On the platform side — **Sumsub**: liveness check, SMS, manual review. “Fast” and “by eye” simply don’t work here. › What was done: → analyzed the verification scenario and Sumsub requirements → built the correct flow: phone number, email, timing → **completed live verification remotely, without account handover** → handled SMS and confirmation codes → brought the process to final approval ▪ Result: → verification passed → access granted → no flags or repeat requests ▪ Live verification is not luck. It’s scenario-based preparation — not hope. › TG: @mustang_service ( https:// t.me/ mustang_service ) › Channel: Mustang Service ( https:// t.me/ +6RAKokIn5ItmYjEx ) *All data is published with the client’s consent.* #verification #sumsub #livecheck #kyc #case
    • IMPORTANT INFO: In a few days, I will switch to completely new code, written from scratch with a new download system, patch building and management system. The Updater will become true 2026 code with "foolproof systems". I'm going to create a Discord server for customers to request new ideas and features. FIRST CUSTOMERS ARE ALREADY USING THE NEW UPDATER ON LIVE SERVERS! Watch this topic for upcoming info because the new updater is around the corner! Yes, you can still use self-update on the previous updater! No, the new updater won't be compatible with the old patch system! A new build is required, but players who already have game files won't have to download the entire patch again! New templates and updates to existing templates are coming soon! Sneak peek:  
    • i used guytis IL project and source. i found in his project there are 3 Client version source... 1,CliExt_H5   --->this one cant be compiled in VS2005,i did know why..is it for H5 client? 2,CliExtNew  --->this one is IL version ,but when i compiled it and use it.player cant login game,MD5Checksum wrong.i check the source code,but not found any hints. 3,L2Server    --->this one for HB client?im not sure...   so my question is what are the differences between these three versions of cliext.dll?how can i fix the issue of the MD5Checksum not matching problem?   01/29/2026 21:04:11.366, [CCliExt::HandleCheckSum] Invalid Checksum[1130415144] vs [-721420287] packet[dd] len[29] sum[2698] key[30] HWID[] Account[]! 01/29/2026 21:04:11.366, SocketLimiter::UserSocketBadunknownprotocol 11111111111 01/29/2026 21:04:11.366, [usersocket]unknown protocol from ip[113.137.149.115]!      
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..