Jump to content
  • 0

Anti AFK TvT L2jacis or L2jfrozen


Question

7 answers to this question

Recommended Posts

  • 0
Posted (edited)
Index: java/com/l2jserver/gameserver/model/actor/L2Character.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/L2Character.java	(revision 2)
+++ java/com/l2jserver/gameserver/model/actor/L2Character.java	(working copy)
 /**
  * Mother class of all character objects of the world (PC, NPC...)<br>
  * L2Character:<br>
@@ -4420,6 +4420,11 @@
 		final int curY = super.getY();
 		final int curZ = super.getZ();
 		
+		if (isPlayer())
+		{
+			getActingPlayer().setLastXY(curX, curY);
+		}
+		
 		// Calculate distance (dx,dy) between current position and destination
 		// TODO: improve Z axis move/follow support when dx,dy are small compared to dz
 		double dx = (x - curX);
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 2)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -14483,4 +14514,47 @@
 		return _hasCharmOfCourage;
 		
 	}
+	
+	final int[] _lastXY = new int[2];
+	
+	public void setLastXY(int x, int y)
+	{
+		_lastXY[0] = x;
+		_lastXY[1] = y;
+	}
+	
+	public boolean isAfk()
+	{
+		return (getX() == _lastXY[0]) && (getY() == _lastXY[1]);
+	}
+	
+	/** Methods to put inside your event when it start and it stop */
+	
+	Future<?> _task;
+	
+	public void stopAfk()
+	{
+		if (_task != null)
+		{
+			_task.cancel(true);
+			_task = null;
+		}
+	}
+	
+	public void startAfk()
+	{
+		stopAfk();
+
+		_task = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
+		{
+			L2World.getInstance().getPlayers().stream().filter(p -> p.isAfk()).forEach(p ->
+			{
+				p.sendMessage("You have been detected as afk.");
+				// Tasks here.
+			});
+			
+		}, 60000, 60000);
+	}
 }
\ No newline at end of file

 

I made you a short code that you can use. 

 

*Note: Make sure to put your boolean method or what you have that checks if player is inside event. Ex. p -> p.isAfk() && p.isInEvent()

Edited by Kara`
  • 0
Posted
1 hour ago, Kara` said:

Index: java/com/l2jserver/gameserver/model/actor/L2Character.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/L2Character.java	(revision 2)
+++ java/com/l2jserver/gameserver/model/actor/L2Character.java	(working copy)
 /**
  * Mother class of all character objects of the world (PC, NPC...)<br>
  * L2Character:<br>
@@ -4420,6 +4420,11 @@
 		final int curY = super.getY();
 		final int curZ = super.getZ();
 		
+		if (isPlayer())
+		{
+			getActingPlayer().setLastXY(curX, curY);
+		}
+		
 		// Calculate distance (dx,dy) between current position and destination
 		// TODO: improve Z axis move/follow support when dx,dy are small compared to dz
 		double dx = (x - curX);
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 2)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -14483,4 +14514,47 @@
 		return _hasCharmOfCourage;
 		
 	}
+	
+	final int[] _lastXY = new int[2];
+	
+	public void setLastXY(int x, int y)
+	{
+		_lastXY[0] = x;
+		_lastXY[1] = y;
+	}
+	
+	public boolean isAfk()
+	{
+		return (getX() == _lastXY[0]) && (getY() == _lastXY[1]);
+	}
+	
+	/** Methods to put inside your event when it start and it stop */
+	
+	Future<?> _task;
+	
+	public void stopAfk()
+	{
+		if (_task != null)
+		{
+			_task.cancel(true);
+			_task = null;
+		}
+	}
+	
+	public void startAfk()
+	{
+		stopAfk();
+
+		_task = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
+		{
+			L2World.getInstance().getPlayers().stream().filter(p -> p.isAfk()).forEach(p ->
+			{
+				p.sendMessage("You have been detected as afk.");
+				// Tasks here.
+			});
+			
+		}, 60000, 60000);
+	}
 }
\ No newline at end of file

 

I made you a short code that you can use. 

 

*Note: Make sure to put your boolean method or what you have that checks if player is inside event. Ex. p -> p.isAfk() && p.isInEvent()

I'm extremely grateful Kara, just get me a single question, I'm using Acis 374, it has no PcInstance.java I believe I have been replaced by Player.java and also does not have ThreadPoolManager.java only ThreadPool.java and also does not have L2Character .java, I believe it has been replaced by Creature.java, if I am wrong could you give me a light? because that slows me down when adding the mod.
I tried putting on the cited files and had errors on the ThreadPool.getInstance ().
Follow the images below;

ThreadPool.java https://imgur.com/r7Kcl9a

Player.java : https://imgur.com/mptTG0A

Creature.java : https://imgur.com/96gP8ao

 

  • 0
Posted

ThreadPool is not using getInstance() anymore - remove it. Simple search over eclipse with ThreadPool would give you an solution. 

  • 0
Posted

if you store somewhere all the players that are in the tvt , instead of World.getInstance().... use the tvt collection about this loop. as main anti-afk this code is good. You can add more conditions and not only checking the location to be more secure 

  • 0
Posted
On 2/28/2022 at 12:31 AM, Kusaty said:

Is work on L2JFROZEN?

Adaption won't be hard for any pack. Also, please consider not to undig old topics. Feel free to create a new one if you struggle.

Guest
This topic is now closed to further replies.
  • Posts

    • how do I make it so that you only deal damage to a mob if you have the right items equipped, like jewels, belt, underwear, bracelet, so if you don't have one of those items equipped, you don't deal any damage to the mob thanks
    • I always welcome bug reports and never ban ppl - until proven leaker - not sure where the "arrogant" part comes from, I would like to know what exactly let you think that (quote me please, and not 12y old quotes as the other frog meme dude). I request bug reports to be properly detailed, otherwise it's a waste of time. Other than that, I don't see where I have been arrogant. I got proper discussions with many ppl, not sure why you wouldn't be one of them.   I got 76 bug reports in my list (21 on forums, 55 on gitlab).   I have a single bug report regarding lvl 4 clan quest, which has to be tested since it's not even clear about what is supposed to be broken. Seven Signs was never reworked and is basically L2J based (we got a rework branch to test/commit with reworked AIs). Geoengine got no specific issues (at my knowledge), pathfinding was reworked lately to be way more performant, and I still try to improve performance using some pool system. Movement was partially fixed in latest 410, and probably will get another rework soon (notably reverting to the task wallclock).   "I" surely didn't spend 12y over geoengine - Hasha cared about geoengine during rev 334 / 354 / 390 / 395 and 397. It is solely his work, and always tagged as it. He was rewarded with money for his work, and almost a decade of aCis access.   aCis is a community work, things tagged with Tryskell is my work, the leftover is someone else work. 22 ppl worked as developers in this project over 14 years.   I would gladly accept whatever list of fixes/reports you have to share. You will even be rewarded (you probably know about cookie system), as anyone else sharing bug report or fixes.   My main concerns lately is the lack of decent L2OFF IL data, it is my main bottleneck actually. If you're aware about decent L2OFF data to parse, let me know.   Eventually reach me over Discord to speak, I don't want to continue the offtopic over that help request.
    • Your project doesn't compare to aCis; you have to be an idiot to use that. I know someone who bought the High Five "PREMIUM" version, which has the same bugs as the free version. If you want, I can share his latest premium version. Players are going through walls with their bad geoengine, falling under the Olympiad. If you want, I can record and prove what I'm saying. The aCis project is 50 steps ahead of yours and it's not even stable...
    • l2jteon, l2joneo l2jscoria etc etc. and from that we went to this 
  • 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..

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock
</