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

    • https://discord.gg/k53SZ4DM5z   Interlude Client L2Old Pride is a L2 Pride Interlude Based All functional skills (Not archer/mage server)   L2Old Pride Helper (Works like Woundrous Cubic) https://imgur.com/iYqmHQY Farm Zones: Cave of Trials and Elven Ruins (Chaotic) Olympiads: Every 15 days Various Cosmetic Items https://imgur.com/uoeU6Jw https://imgur.com/oCS2Zed PvP Zone: Gludin Village (No-Parties, Disguised) More than 100 new Skills https://imgur.com/6RaPsQV Max Level: 90 https://imgur.com/z4QVJKZ Gaining Xp by PVP https://imgur.com/LRqI31T Purchasable S-grade items +10 or +20 with random chance to enchant +5 Purchasable Custom Items Depends on Tier Mysterious Merchants https://imgur.com/2ZwWyPH Auto Enchant Via PvPing (with low chance) Custom Raid Bosses Siege Every Weekend (Aden, Rune, Giran) Autofarm / Drop Tracker https://imgur.com/Vz3rha6   RATES: • Start Level 80 • Max level 90  • EXP: 5000x • SP: 5000x • ADENA 6000x   ENCHANT: • Maximum enchant S Grade Items: +35. • Maximum enchant Unique/Epic Items: +25. • Maximum enchant Legendary Items: +18. • Maximum enchant Relic Items: +14. •Descriptions for rate at scrolls!   EVENTS: • TEAMS vs TEAMS • CAPTURE THE FLAG • DOMINATION • DEATH MATCH • DICE OF DEATH • CHAOTIC ZONE   OTHERS: Assistance system in pvps. Where support classes are enabled to receive pvp with a low chance, for supporting a party member during pvp. •  /sit to regen HP/MP/CP • Custom Shots Glows https://imgur.com/FLK0DmR • Achievements System • Daily Tasks System • Monthly Tasks System   CUSTOM ARMORS SETS Dread Armor/Titanium Armor Pride Armor Rykros Armor https://imgur.com/SPxoQp1   CUSTOM WEAPONS SETS Unique Weapons Pride Weapons Legendary Weapons Relic Weapons https://imgur.com/kOHNXhS   CUSTOM ACCESSORIES Standard Superior Legendary https://imgur.com/zPqNiiX   CUSTOM JEWELS/TATTOO Legendary Nightmarish https://imgur.com/gcqS28P There are many more features that you will only understand by playing and following. Beta testing server is currently open. Follow us on our discord and join our server to test it.
    • You shouldn't use rev 382, not sure why everyone keep using that.   I don't make changesets for fun, I don't make new revisions for nothing.   Follow the revisions.
    • Your issue isn't related to geoengine at all (as always), rev 410 got improved water movement management.
    • Download Here: https://sitehunterus.blogspot.com/2025/12/custom-proxy-checker-check-proxies.html VirusTotal https://www.virustotal.com/gui/file/b74418850d82dbf0031e0549f20239b5bff5dbba7a59903fcf9ba55780002a4e Visit my Blogger list to download 100% free software https://www.freetoolss.com/ https://blackhat8.blogspot.com/ https://hack-crack9.blogspot.com/ https://hackernoons.blogspot.com/ https://sharetools99.blogspot.com/
  • Topics

×
×
  • Create New...

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