Jump to content

Recommended Posts

Posted

Had a big issue with afkers in my tvt event, so I whipped this up really quick. Only Tested on Freya, maybe will work on Hi5, maybe not.

 

It checks every 1 min(default setting), if tvt is started or not. If it is, it then checks every player in tvt, x/y/z locations and if they are fighting or casting, every 1 min.  If the player has been in the same x/y/z location and not fighting/casting 4 times(default setting) in a row, it simply boots them from the server.

 

Ran on live server 6+ months with no problems and flawlessly. Only works on servers that don't have massive spawn killing at tvt events(because of random offset respawn). This one uses no database connections.

 

This script requires one SMALL core patch.

In CORE com.l2jserver.gameserver.model.entity.TvTEvent.java file, find near the TOP of the code this line..

 
    private static TvTEventTeam[] _teams = new TvTEventTeam[2];

And change it to this

 
    public static TvTEventTeam[] _teams = new TvTEventTeam[2];

Now rebuild and install your new l2jserver.jar.

 

Create a new folder named AntiAfk in your server files under gameserver/data/scripts/custom and put this script into it.

AntiAfkTvt.java

package custom.AntiAfk;

import java.util.ArrayList;
import java.util.logging.Logger;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.entity.TvTEventTeam;

/** 
*
* @author Phear3d
*/

public class AntiAfkTvt
{
    // Debug
    private static boolean debug = false;
    // Delay between location checks , Default 60000 ms (1 minute)
    private final int CheckDelay = 30000;
   
    private static Logger _log = Logger.getLogger(AntiAfkTvt.class.getName());
private static ArrayList<String> TvTPlayerList = new ArrayList<String>();
private static String[] Splitter;
private static int xx,yy,zz,SameLoc;
private static L2PcInstance _player;

   private AntiAfkTvt()
   {
       _log.info("AntiAfkTvt: Auto-Kick AFK in TVT System initiated.");
       ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AntiAfk(), 60000, CheckDelay);
   }

   private class AntiAfk implements Runnable
   {
       public void run()
       {
     	  if (TvTEvent.isStarted())
     	  {
     		  // Iterate over all teams
     		  for (TvTEventTeam team : TvTEvent._teams)
     		  {
     			  // Iterate over all participated player instances in this team
     			  for (L2PcInstance playerInstance : team.getParticipatedPlayers().values())
     			  {
     				  if (playerInstance != null && playerInstance.isOnline())
     				  {
     					  _player = playerInstance;
     					  AddTvTSpawnInfo(playerInstance.getName(),playerInstance.getX(),playerInstance.getY(),playerInstance.getZ());
     					  if (debug)
     						  System.err.println("TvT Player: " + playerInstance.getName() + " " + playerInstance.getX() + " " +  playerInstance.getY() + " " +  playerInstance.getZ());
     				  }
     			  }
     		  }
     	  }
     	  else
     	  {
     		  TvTPlayerList.clear();
     	  }
       }
   }
   
private static void AddTvTSpawnInfo(String name, int _x, int _y, int _z)
{
	if(!CheckTvTSpawnInfo(name))
	{
		String temp = name + ":" + Integer.toString(_x) + ":" + Integer.toString(_y) + ":" + Integer.toString(_z) + ":1";
		TvTPlayerList.add(temp);
	}
	else
	{
        Object[] elements = TvTPlayerList.toArray();
        for(int i=0; i < elements.length ; i++)
        {
        	Splitter = ((String) elements[i]).split(":");
        	String nameVal = Splitter[0];
		       if (name.equals(nameVal))
		       {
		    	   GetTvTSpawnInfo(name);
		    	   if (_x == xx && _y == yy && _z == zz && _player.isAttackingNow() == false && _player.isCastingNow() == false && _player.isOnline() == true && _player.isParalyzed() == false)
		    	   {
		    		   ++SameLoc;
		    		   if (SameLoc >= 4)//Kick after 4 same x/y/z, location checks
		    		   {
		    			   //kick here
		    			   TvTPlayerList.remove(i);
		    			   _player.logout();
		    			   return;
		    		   }
		    		   else
		    		   {
		    			   TvTPlayerList.remove(i);
		    			   String temp = name + ":" + Integer.toString(_x) + ":" + Integer.toString(_y) + ":" + Integer.toString(_z) + ":" + SameLoc;
		    			   TvTPlayerList.add(temp);
		    			   return;
		    		   }
		    	   }
		    	   TvTPlayerList.remove(i);
				   String temp = name + ":" + Integer.toString(_x) + ":" + Integer.toString(_y) + ":" + Integer.toString(_z) + ":1";
				   TvTPlayerList.add(temp);
		       }
        }
	}
}

private static boolean CheckTvTSpawnInfo(String name)
{

        Object[] elements = TvTPlayerList.toArray();
        for(int i=0; i < elements.length ; i++)
        {
        	Splitter = ((String) elements[i]).split(":");
        	String nameVal = Splitter[0];
	       if (name.equals(nameVal))
	       {
		       return true;
	       }
        }
        return false;
}

private static void GetTvTSpawnInfo(String name)
{

        Object[] elements = TvTPlayerList.toArray();
        for(int i=0; i < elements.length ; i++)
        {
        	Splitter = ((String) elements[i]).split(":");
        	String nameVal = Splitter[0];
	       if (name.equals(nameVal))
	       {
		       xx = Integer.parseInt(Splitter[1]);
		       yy = Integer.parseInt(Splitter[2]);
		       zz = Integer.parseInt(Splitter[3]);
		       SameLoc = Integer.parseInt(Splitter[4]);
	       }
        }
}

   public static AntiAfkTvt getInstance()
   {
       return SingletonHolder._instance;
   }

   @SuppressWarnings("synthetic-access")
   private static class SingletonHolder
   {
       protected static final AntiAfkTvt _instance = new AntiAfkTvt();
   }

   public static void main(String[] args)
   {
   AntiAfkTvt.getInstance();
   }
}

 

Finally, edit your scripts.cfg file and add.......

 
custom/AntiAfk/AntiAfkTvt.java

Posted

In the code it checks every 30000 ms so 30 seconds  not  1 minute

 

indeed. Copy/pasted the post from my original post on l2jserver forums to here, and my current live code (which has been adjusted a little)

8)

 

that is why it says "It checks every 1 min(default setting)" , in the code also.. ;)

Posted

If you are afk that very specific momment of check, i mean: u play but u stay afk 2 sec, and in those 2 sec the check takes place, you are considered afk? if yes fail bad coded trash, otherwise a very good one

Posted

If you are afk that very specific momment of check, i mean: u play but u stay afk 2 sec, and in those 2 sec the check takes place, you are considered afk? if yes fail bad coded trash!!!

 

It checks every 1 min(default setting), if tvt is started or not. If it is, it then checks every player in tvt, x/y/z locations and if they are fighting or casting, every 1 min.  If the player has been in the same x/y/z location and not fighting/casting 4 times(default setting) in a row, it simply boots them from the server.

  • 6 months later...
  • SweeTs locked this topic
Guest
This topic is now closed to further replies.


  • Posts

    • From Salvation onwards I think you need a patched nwindow.dll that allows such modifications, try to see if you get what you need here: https://drive.google.com/drive/u/1/folders/1LLbQFGf8KlR-O0Iv5umfF-pwZgrDh9bd
    • hello everyone! I am wanting to save the files (Ini. - Data - ) of the EP5 Client: Salvation... But they generate the error "corrupt files"... I tried several versions of L2FileEditor without good results. I need help! Thank you!
    • Opening December 6th at 19:00 (GMT +3)! Open Beta Test from November 30th!   https://l2soe.com/   🌟 Introducing L2 Saga of Eternia: A Revolution in Lineage 2 High Five! 🌟   Dear Lineage 2 enthusiasts, Prepare to witness the future of private servers! L2 Saga of Eternia is not just another High Five project—it’s a game-changing experience designed to compete with the giants of the Lineage 2 private server scene. Built for the community, by the community, we’re here to raise the bar in quality, innovation, and longevity. What Sets Us Apart? 💎 No Wipes, Ever Say goodbye to the fear of losing your progress. Our server is built to last and will never close. Stability and consistency are our promises to you. ⚔️ Weekly New Content Our dedicated development team ensures fresh challenges, events, and updates every week. From custom quests to exclusive features, there will always be something exciting to explore. 💰 No Pay-to-Win Skill and strategy matter most here. Enjoy a balanced gameplay environment where your achievements come from effort, not your wallet. 🌍 A Massive Community With 2000+ players expected, join a vibrant and active community of like-minded adventurers ready to conquer the world of Aden. 🏆 Fair and Competitive Gameplay Our systems are designed to promote healthy competition while avoiding abusive mechanics and exploits. 🔧 Professional Development From advanced bug fixes to carefully curated content, we pride ourselves on smooth performance, no lag, and unparalleled server quality. Key Features Chronicle: High Five with unique interface Rate: Dynamic x10 rates Class Balance: Carefully fine-tuned for a fair experience PvP Focused: PvP Ranking & aura display effect for 3 Top PvPers every week Custom Events: Seasonal and permanent events to keep you engaged Additional Features:   Custom Endgame Content: Introduce unique dungeons, raids, or zones unavailable in other servers. Player-Driven Economy: Implement a strong market system and avoid overinflated drops or rewards. Epic Siege Battles: Announce special large-scale sieges and PvP events. Incentives for Streamers and Clans: Attract influencers and big clans to boost server publicity. Roadmap Transparency: Share a public roadmap of planned updates to build trust and excitemen   Here you can read all the features: https://l2soe.com/features   Video preview: Join the Revolution! This is your chance to be part of something legendary. L2 Saga of Eternia is not just a server; it’s a movement to redefine what Lineage 2 can be. Whether you’re a seasoned veteran or a newcomer to the world of Aden, we invite you to experience Lineage 2 at its finest.   Official Launch Date: December 6th 2024 Website: https://l2soe.com/ Facebook: https://www.facebook.com/l2soe Discord: https://discord.com/invite/l2eternia   Let’s build the ultimate Lineage 2 experience together. See you in-game! 🎮
    • That's like a tutorial on how to run l2 on MacOS Xd but good job for the investigation. 
  • Topics

×
×
  • Create New...