Jump to content

Question

Posted

Hello i have a problem with this code i get no errors in eclipse but in game it doesnt work..

to Player.java

if (getParty() != null)
		{
			for (Player p : getParty().getMembers())
			{
				if (Config.Synergy_Class.contains(p.getClassId().getId()) && p.isInCombat() && (Rnd.get(100) <= 90))
				{
					p.sendMessage("You have earned a pvp by supporting " + target.getName());
					p.getPvpKills();
				}
			}
		}


and the config
  
  public static List<Integer> Synergy_Class = new ArrayList<>();


  	String Synergy_Class = customs.getProperty("ClassesSupp", "97");
		String[] atdc_splitted = Synergy_Class.split(",");
		for (String s : atdc_splitted)
		{
			Synergy_Class.add(Integer.valueOf(s));
		}

Recommended Posts

  • 1
Posted (edited)
1 hour ago, melron said:

@Evie Frye the guy didnt ask for new assist system but asked for a fix in this one (even if it is not good) so i answered to this one. Feel free to sell your services to him :D kisses 

 

Sell? Bitches, you're all my fans !

Index: java/com/l2evie/gameserver/model/Assist.java
===================================================================
--- java/com/l2evie/gameserver/model/Assist.java	(revision 0)
+++ java/com/l2evie/gameserver/model/Assist.java	(revision 0)
@@ -0,0 +1,36 @@
+package com.l2evie.gameserver.model;
+
+import com.l2evie.gameserver.model.actor.instance.L2PcInstance;
+
+public class Assist
+{
+	private final L2PcInstance _owner;
+	private int _totalHeal = 0;
+	private long _lastHeal = 0;
+	
+	public Assist(final L2PcInstance player)
+	{
+		_owner = player;
+	}
+	
+	public L2PcInstance getPlayer()
+	{
+		return _owner;
+	}
+	
+	public int getTotalHeal()
+	{
+		return _totalHeal;
+	}
+	
+	public long lastHeal()
+	{
+		return _lastHeal;
+	}
+	
+	public void addHealPoints(int points)
+	{
+		_lastHeal = System.currentTimeMillis();
+		_totalHeal =+ points;
+	}
+}
Index: java/com/l2evie/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2evie/gameserver/model/actor/instance/L2PcInstance.java	(revision 2)
+++ java/com/l2evie/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -98,6 +98,7 @@
 import com.l2evie.gameserver.instancemanager.TerritoryWarManager;
 import com.l2evie.gameserver.instancemanager.TownManager;
+import com.l2evie.gameserver.model.Assist;
 import com.l2evie.gameserver.model.BlockList;
 import com.l2evie.gameserver.model.CharEffectList;
 import com.l2evie.gameserver.model.CursedWeapon;
@@ -6108,9 +6109,24 @@

 		setPvpKills(getPvpKills() + 1);
+			
+		for (Assist assist : getAllAssist())
+		{
+			if (getParty() == null || assist.getPlayer() == null || assist.lastHeal() + (15 * 1000) <= System.currentTimeMillis())
+			{
+				removeAssist(assist);
+			}
+			else if (getParty().getPartyMembers().contains(assist.getPlayer()) && Util.calculateDistance(this, assist.getPlayer(), false) <= 1450)
+			{ 
+				assist.addHealPoints(0);
+				assist.getPlayer().setPvpKills(assist.getPlayer().getPvpKills() + 1);
+				assist.getPlayer().sendMessage("You received 1 pvp kill for assisting player " + getName());
+			}
+		}
+			
  	
 	public void waitSecs(final int i)
@@ -16559,4 +16575,21 @@
 	{
 		return _unlockable;
 	}
+	
+	private final HashMap<Integer, Assist> _assist = new HashMap<>();
+	
+	public Assist getAssist(int healerId)
+	{
+		return _assist.get(healerId) !=null ? _assist.get(healerId) : _assist.put(healerId, new Assist(L2World.getInstance().getPlayer(healerId)));
+	}
+	
+	public void removeAssist(final Assist assist)
+	{
+		_assist.remove(assist);
+	}
+	
+	public Collection<Assist> getAllAssist()
+	{
+		return _assist.values();
+	}
 }
\ No newline at end of file

Also in Heal.java or i dont know what other files exist. 

 

if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance)
{
	final L2Party party = ((L2PcInstance) activeChar).getParty();
			
	if (party !=null && party.getPartyMembers().contains(((L2PcInstance) target)))
	{
		if (((L2PcInstance) activeChar).isInCombat() && !((L2PcInstance) activeChar).getAttackByList().isEmpty() && !((L2PcInstance) activeChar).getAttackByList().contains(target))
		{
			((L2PcInstance) target).getAssist(activeChar.getObjectId()).addHealPoints((int) hp);
		}
	}
}

 

Ps its not tested or so. But just the idea. 

Edited by Evie Frye
  • 0
Posted

what this one supposed to do? Increase pvp in supporter class? if yes
replace
 

p.getPvpKills();

with this

p.setPvpKills(p.getPvpKills() +1);

 

  • 0
Posted
1 hour ago, ThelwHelpRePaidia said:

i've tried it but it doesnt work and like that  xD

then the location of your code is wrong or you do not meet the conditions. add debugs for each boolean for all these 'if' and check out whats going on

  • 0
Posted

How you expect people to help you? You don't provide any info just some fail coding. 

Where did you place the code? What are your configurations? Does the message appear ? Possibly you've added the code in wrong place

or you ignored the config and you haven't add your class ID in their. Or even worst the config is wrong and u just didn't see the error

because config errors appear upon server load which is barely visible. 

  • 0
Posted
3 minutes ago, Evie Frye said:

How you expect people to help you? You don't provide any info just some fail coding. 

Where did you place the code? What are your configurations? Does the message appear ? Possibly you've added the code in wrong place

or you ignored the config and you haven't add your class ID in their. Or even worst the config is wrong and u just didn't see the error

because config errors appear upon server load which is barely visible. 

holy shit

  • 0
Posted (edited)

1st im getting 0 errors on eclipse and on gameserver

2nd i dont get the message

3rd i placed the code here

public void onKillUpdatePvPKarma(Playable target)
	{
		if (target == null)
			return;
		
		final Player targetPlayer = target.getActingPlayer();
		if (targetPlayer == null || targetPlayer == this)
			return;
		
		// Don't rank up the CW if it was a summon.
		if (isCursedWeaponEquipped() && target instanceof Player)
		{
			CursedWeaponsManager.getInstance().increaseKills(_cursedWeaponEquippedId);
			return;
		}
		
		// If in duel and you kill (only can kill l2summon), do nothing
		if (isInDuel() && targetPlayer.isInDuel())
			return;
		
		if (EventManager.getInstance().isRunning() && EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRegistered(targetPlayer))
			return;
		
		if (getParty() != null)
		{
			for (Player player : getParty().getMembers())
			{
				if (Config.Synergy_Class.contains(player.getClassId().getId()) && player.isInCombat() && (Rnd.get(100) <= 90))
				{
					player.sendMessage("You have earned a pvp by supporting " + target.getName());
					player.setPvpKills(player.getPvpKills() + 1);
				}
			}
		}
		// If in pvp zone, do nothing.
		if (isInsideZone(ZoneId.PVP) && targetPlayer.isInsideZone(ZoneId.PVP))
		{
			// Until the zone was a siege zone. Check also if victim was a player. Randomers aren't counted.
			if (target instanceof Player && getSiegeState() > 0 && targetPlayer.getSiegeState() > 0 && getSiegeState() != targetPlayer.getSiegeState())
			{
				// Now check clan relations.
				final Clan killerClan = getClan();
				if (killerClan != null)
					killerClan.setSiegeKills(killerClan.getSiegeKills() + 1);
				
				final Clan targetClan = targetPlayer.getClan();
				if (targetClan != null)
					targetClan.setSiegeDeaths(targetClan.getSiegeDeaths() + 1);
			}
			return;
		}

 

Edited by ThelwHelpRePaidia
  • 0
Posted

Try add the code after this: 

  // Check if it's pvp (cases : regular, wars, victim is PKer)
  if (checkIfPvP(target) || (targetPlayer.getClan() != null && getClan() != null && getClan().isAtWarWith(targetPlayer.getClanId()) && targetPlayer.getClan().isAtWarWith(getClanId()) && targetPlayer.getPledgeType() != Clan.SUBUNIT_ACADEMY && getPledgeType() != Clan.SUBUNIT_ACADEMY) || (targetPlayer.getKarma() > 0 && Config.KARMA_AWARD_PK_KILL))
  {
   if (target instanceof Player)
   {

        //here

 

  • 0
Posted (edited)

How many times did you test it? I mean how many kills did you got?

 

As you didnt understood my last suggestion i will explain you:

 

You have to meet 4 conditions in order the party member to get pvp point too.

 

  • Be in party
  • Config got the user class id
  • user is in combat
  • And 90% chance.

 

Are you sure for all these conditions ?

 

Why you do not simply add debugs to check it?

 

if (getParty() != null)
{
	for (Player player : getParty().getMembers())
	{
		final int rnd = Rnd.get(100);
		System.out.println("Checking for " + player.getName() + " Conditions...");
		System.out.println(Config.Synergy_Class.contains(player.getClassId().getId()) ? "Config missing player's class ID!" : " Config got player's ID!");
		System.out.println(player.isInCombat() ? " Player is in combat!" : " Player is not in combat!");
		System.out.println(rnd <= 90 ? " Chance is OK!" : " Chance is not OK! ( " + rnd + "");
		System.out.println(Config.Synergy_Class.contains(player.getClassId().getId()) && player.isInCombat() && (rnd <= 90) ? " Reward can be given!" : " Cannot give the reward!");
		if (Config.Synergy_Class.contains(player.getClassId().getId()) && player.isInCombat() && (rnd <= 90))
		{
			player.sendMessage("You have earned a pvp by supporting " + target.getName());
			player.setPvpKills(player.getPvpKills() + 1);
		}
	}
}
else
	System.out.println("No party found.");

 

Edited by melron
  • 0
Posted (edited)

@melron it's working like this but im getting something that it seems weird i dont get +1 pvp i get the pvps that my party mate has if he has 551 and me 0 if he gets pvp i will go 552

 

Party party = getParty();
				
				if (party != null)
				{
					for (Player partymate : party.getMembers())
					{
						if (partymate == null)
							continue;
						
						if (partymate.getClassId().getId() == 97 && partymate.isInCombat() && partymate.getPvpFlag() > 0)
						{
							if (partymate.isInsideRadius(this, 1100, false, false))
							{
								if (Rnd.nextInt(100) < 100)
								{
									partymate.setPvpKills(partymate.getPvpKills() + 1);
									break;
								}
							}
						}
					}
				}
				
					
					// Add PvP point to attacker.
					setPvpKills(getPvpKills() + 1);

 

Edited by ThelwHelpRePaidia
  • 0
Posted
				for(Player member : getParty().getMembers())
				{
					if(member != null)
					{
						if(member.getClassId().getId() == 97 && member.isInCombat() && member.isInsideRadius(this, 1100, false, false) && Rnd.nextInt(100) < 100)
						{
							setPvpKills(getPvpKills() + 1);
						}
					}
				}

i dont know if help this

  • 0
Posted (edited)
3 hours ago, ThelwHelpRePaidia said:

@melron it's working like this but im getting something that it seems weird i dont get +1 pvp i get the pvps that my party mate has if he has 551 and me 0 if he gets pvp i will go 552

 

 

 

  • Check the method setPvpKills and getPvpKills maybe you forgot to delete some custom things inside
  • Add a check for same player like 
if (partymate == this)
     continue;
  • Remove break, you dont need this

 

about the pvp value issue, probably when you compiled your code was like this

 

if (Rnd.nextInt(100) < 100)
{
	partymate.setPvpKills(getPvpKills() + 1);
	break;
}

 

Edited by melron
  • 0
Posted (edited)

Holy shit with these answers.

 

I imagine Melron and Tazerman in a group of superheroes fighting against stackoverflow bad guys! This would be more epic than Avengers which is coming in 2 months. Speaking of assist. You must make it a bit more "comblex" in order to work properly. Example each player must have a holder of the healerId (the objectId of person who healed it) & the heal ammount. Upon kill it must check the healAmmount if > than Rnd(X) and if the objectId (healer) is still in range to give him +1 pvp. 

so basically a

private final HashMap<Integer, Long> _healerData = new HashMap<>():
  
public HashMap<Integer, Long> getHealerData()
{
  return _healerData;
}
  
public void addHeal(int objectId, long heal)
{
 	if (_healerData.containsKey(objectId))
  	{
   		_healerData.put(objectId, _healerData.get(objectId) + heal);
  	}
  	else
  	{
  		_healerData.put(objectId, heal);
  	}
}

at Heal.java do something

if (target instanceof L2PcInstance && target.getParty() !=null && target.getParty().containMember(activeChar)
{
 	((L2PcInstance) target).addHeal(activeChar.getObjectId(), healAmmount);
}

and in increasePvPKills() method reset the data for > X ammounts of heal and give reward.

 

All these.. Rnd and Rnd its amateur and useless. If you want to make a assist system at least make it properly. Consider the code i also wrote is fail by default cause mostly i didn't even sit to think about it + i didn't open intellij but just to give you the idea of how not properly working is the code you post.

Edited by Evie Frye
  • 0
Posted (edited)

@Evie Frye the guy didnt ask for new assist system but asked for a fix in this one (even if it is not good) so i answered to this one. Feel free to sell your services to him :D kisses 

Edited by melron

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

    • ## [1.5.5] - 2026-02-02   ### ✨ New Features - **Discord Login**: You can now sign in with your Discord account. Admins enable and configure Discord login in **cpadmin → Users** (Discord auth settings: Client ID, Client Secret, Redirect URI). If you already have an account with the same email (e.g. forum, Google, or legacy), signing in with Discord links to that account so you keep one profile. Discord login is available on Add Server, My Servers, Vote page, and Premium Ads booking. - **Setup Links**: In **cpadmin → Users**, both Google and Discord login settings now include direct links to their official developer portals (Google Cloud Console and Discord Developer Portal) for easier OAuth app setup.   ### 🔒 Security - **Email Required for Registration**: New user registration via OAuth (Forum, Google, Discord) now requires a valid email address. If the OAuth provider doesn't provide an email (e.g. unverified Discord email), registration is rejected with a clear message. This prevents anonymous accounts and ensures all users can receive important notifications.   ### 🔄 Improvements - **User Auth Badges**: In **cpadmin → Users**, the Registered Members table now shows auth method badges: **Forum**, **Google**, **Discord**, or **Legacy**. Users can have multiple badges if they've linked multiple login methods. - **Server Info Labels**: Translated server info labels (Owner Name, Language, Server Location) are now properly localized in all 5 languages (English, Spanish, Portuguese, Greek, Russian).   ---   ## [1.5.4] - 2026-02-01   ### ✨ New Features - **Google Login**: You can now sign in with your Google account. Admins enable and configure Google login in **cpadmin → Users** (Google auth settings: Client ID, Client Secret, Redirect URI). If you already have an account with the same email (e.g. forum or legacy), signing in with Google links to that account so you keep one profile. The login menu (navbar and login prompts) offers **Login with Forum Account**, **Login with Google** (when enabled), and **Create Forum Account**. Google login is available on Add Server, My Servers, Profile Settings, Vote page, and Premium Ads booking. - **Ban/Unban Members**: In **cpadmin → Users**, admins can ban or unban registered members. Banned users see a full-page message: "Sorry, you are banned from using this site." When a user is banned, all their servers are set to inactive. - **Moderator Activity Log**: **cpadmin → Moderators** now records when a moderator or admin enters the CPAdmin panel (e.g. "Moderator X entered CPAdmin panel at &lt;time&gt;") and when they change any cpadmin settings (only write actions are logged; read-only use is not). - **Clear Moderator Logs**: Admins can clear all moderator activity log entries via a **Clear logs** button with confirmation. Logs are shown at 100 per page with pagination. - **Filter by Moderator**: In the Moderator Activity Log, a **Filter by moderator** dropdown lets you view activity for a specific moderator or "All moderators." - **cpadmin → Users Tab**: New **Users** tab in the admin panel with Registered Members list (paginated), Google auth settings card, and per-user Ban/Unban and server links.   ### 🔄 Improvements - **cpadmin → Servers**: Each server name in the servers table is now clickable and opens that server’s info page. - **cpadmin → Users – Servers column**: The servers count/list is clickable and opens a small modal listing that user’s servers; each server name in the modal links to the server info page. - **cpadmin → Users – Search**: A search bar above the Registered Members table lets you search by **username**, **email**, or **server name**. Results are filtered on the server (paginated); clearing the search resets the list. - **Moderator Activity Log**: Pagination shows "Showing X–Y of Z" and "Page N of M" with Previous/Next when there are more than 100 entries. - **Login UI**: Login options (Forum, Google, Create account) are shown in a consistent dropdown and in modals (Add Server, My Servers, Vote, Premium Ads) for a clearer sign-in experience. - **Vote Page – Unauthenticated**: When you must log in to vote, the page now shows "Vote for [Server Name]" as the main heading and presents login options in a compact section.   ---   ## [1.5.3] - 2026-01-30   ### ✨ New Features - **File Logs in Admin Panel**: Admins can now view CodeIgniter PHP logs (api/writable/logs) directly in **cpadmin → Logs**. Select a date to view the log file, refresh to reload, or delete all log files to free up space.   ### 🔄 Improvements - **Cache System**: Full cache audit and improvements — when you clear cache in cpadmin, both backend and frontend caches are cleared. Server listings, My Servers, pricing, ad config, and chronicles all refresh with fresh data. New paid servers now appear in listings and My Servers immediately. - **Admin Panel – Server Rates**: Server rates in the admin servers table now display in compact format (e.g. x10000 → x10k, x100000 → x100k, x1000000 → x1m) for easier scanning. Hover to see the full value.
    • WTB High Five source running on Salvation/Fafurion client
    • MoMoProxy has updated more static residential proxies for USA location, anyone interested in can view: https://momoproxy.com/static-residential-proxies
    • Hello, i am selling a project that was going to open but at the end i have not the time to do it Its a c4 server ( scripts) with all the c5 changes played from Interlude Client    the server is 1:1 copy of the legendary 2007 L2Revenge server with some bits like events and some more sync stuff There is a lot of retail fixes included  , extender is vanganth and has a lot of mods but mostly fixes on the retail stuff.   Test server is available through discord , i offer client/patch/server/sources The price is 300 Euro and for testing the server you have to pm me at discord banshee1019 , dont really wanna let anybody log because some people are "bad"   Once you buy you also have free support for 1 year , that doesnt mean i will code all your ideas but support you if something comes up , and guide you to do simple edits
  • 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..