Jump to content
  • 0

Question

Posted (edited)

I'm limiting players from the same IP in a zone, but I'm not having much success, I'm using AntiFeed to do this action.

 

Code:

if ((_maxPlayers > 0) && !AntiFeedManager.getInstance().tryAddPlayer(getId(), player, _maxPlayers))
			{
				player.sendPacket(new ExShowScreenMessage(player.getName() + " maximum "+ AntiFeedManager.getInstance().getLimit(player, _maxPlayers) +" connection(s) per IP address allowed.", 5000, SMPOS.TOP_CENTER, true));
				player.teleportTo(TeleportType.TOWN);
				return;
			}

 

on the first try when I go to the zone I am moved out with no (Boot) inside the zone. On the second attempt I remain and if I log a boot the same procedure happens and I am allowed to keep 2. What is an ideal solution to block multiple players with the same IP?

Edited by Vision

8 answers to this question

Recommended Posts

  • 0
Posted

Few to none relevant information regarding your issue. You pasted few lines of code which we know nothing about or where you placed it. Also, you mention that you use 'AntiFeed', which basically is something custom we know nothing about, there's not enough info to help you.

 

If you want to block 2 players that use the same ip from accessing a zone, the best way is to check their ip when they enter the zone. If another player that is in the same zone shares the same ip, don't let the player enter (tp him back). There's no way players can cheat their way through, unless your movement system/zone system is fcked. If you feel players can cheat their way into the zone, you can additionally run a task every X minutes/seconds to check for players using the same ip inside the restricted zone and kick them.

  • 0
Posted (edited)

  

On 10/13/2022 at 10:03 AM, An4rchy said:

Few to none relevant information regarding your issue. You pasted few lines of code which we know nothing about or where you placed it. Also, you mention that you use 'AntiFeed', which basically is something custom we know nothing about, there's not enough info to help you.

 

If you want to block 2 players that use the same ip from accessing a zone, the best way is to check their ip when they enter the zone. If another player that is in the same zone shares the same ip, don't let the player enter (tp him back). There's no way players can cheat their way through, unless your movement system/zone system is fcked. If you feel players can cheat their way into the zone, you can additionally run a task every X minutes/seconds to check for players using the same ip inside the restricted zone and kick them.

 

or you can make the character that is in the zone to be teleported out as soon as other character with same ip enters zone. this is undestroyable.

 

onEnter.

 

for (Player player1 : World.getInstance().getPlayers())
                {
                    if (player1.isInsideZone(ZoneId.YOURZONEID) && player1.getClient().getConnection().getInetAddress().getHostAddress() == player.getClient().getConnection().getInetAddress().getHostAddress() )
                    {
                        player1.abortAttack();
                        player1.abortCast();
                        player1.teleportTo(TeleportType.TOWN);
                        player.sendMessage("You're character that is using same ip address has been teleported out from this area. Dual-Box is not allowed in this zone.")
                    player1.sendMessage("You have been teleported out. Dual-Box is not allowed in this zone..");
                    }
                }

 

 

 

if you want to have only 2 players with same ip use this::serious:

 

        int a = 0;

for (Player player1 : World.getInstance().getPlayers())
                {

           
                    if (player1.isInsideZone(ZoneId.YOURZONEID) && player1.getClient().getConnection().getInetAddress().getHostAddress() == player.getClient().getConnection().getInetAddress().getHostAddress() )
                    {

                       a = a++;

                       if(a > 1){
                        player1.abortAttack();
                        player1.abortCast();
                        player1.teleportTo(TeleportType.TOWN);
                        player.sendMessage("You're character that is using same ip address has been teleported out from this area. Dual-Box is not allowed in this zone.")
                    player1.sendMessage("You have been teleported out. Dual-Box is not allowed in this zone..");

                    }
                    }
                }

 

 

Edited by arm4729
  • 0
Posted
5 hours ago, An4rchy said:

Few to none relevant information regarding your issue. You pasted few lines of code which we know nothing about or where you placed it. Also, you mention that you use 'AntiFeed', which basically is something custom we know nothing about, there's not enough info to help you.

 

If you want to block 2 players that use the same ip from accessing a zone, the best way is to check their ip when they enter the zone. If another player that is in the same zone shares the same ip, don't let the player enter (tp him back). There's no way players can cheat their way through, unless your movement system/zone system is fcked. If you feel players can cheat their way into the zone, you can additionally run a task every X minutes/seconds to check for players using the same ip inside the restricted zone and kick them.

 

package net.sf.l2j.gameserver.data.manager;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.Creature;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.network.GameClient;

public class AntiFeedManager
{
	public static final int GAME_ID = 0;
	public static final int OLYMPIAD_ID = 1;
	public static final int EVENT_ID = 2;
	
	private final Map<Integer, Long> _lastDeathTimes = new ConcurrentHashMap<>();
	private final Map<Integer, Map<Integer, AtomicInteger>> _eventIPs = new ConcurrentHashMap<>();
	
	/**
	 * Set time of the last player's death to current
	 * @param objectId Player's objectId
	 */
	public void setLastDeathTime(int objectId)
	{
		_lastDeathTimes.put(objectId, System.currentTimeMillis());
	}
	
	/**
	 * Check if current kill should be counted as non-feeded.
	 * @param attacker Attacker character
	 * @param target Target character
	 * @return True if kill is non-feeded.
	 */
	public boolean check(Creature attacker, Creature target)
	{
		if (!Config.ANTIFEED_ENABLE)
			return true;
		
		if (target == null)
			return false;
		
		final Player targetPlayer = target.getActingPlayer();
		if (targetPlayer == null)
			return false;
		
		// Players in offline mode should't be valid targets.
		if (targetPlayer.getClient().isDetached())
			return false;
		
		if ((Config.ANTIFEED_INTERVAL > 0) && _lastDeathTimes.containsKey(targetPlayer.getObjectId()) && ((System.currentTimeMillis() - _lastDeathTimes.get(targetPlayer.getObjectId())) < Config.ANTIFEED_INTERVAL))
			return false;
		
		if (Config.ANTIFEED_DUALBOX && (attacker != null))
		{
			final Player attackerPlayer = attacker.getActingPlayer();
			if (attackerPlayer == null)
				return false;
			
			final GameClient targetClient = targetPlayer.getClient();
			final GameClient attackerClient = attackerPlayer.getClient();
			if ((targetClient == null) || (attackerClient == null) || targetClient.isDetached() || attackerClient.isDetached())
				return !Config.ANTIFEED_DISCONNECTED_AS_DUALBOX; // unable to check ip address
			
			return !targetClient.getConnection().getInetAddress().equals(attackerClient.getConnection().getInetAddress());
		}
		
		return true;
	}
	
	/**
	 * Clears all timestamps
	 */
	public void clear()
	{
		_lastDeathTimes.clear();
	}
	
	/**
	 * Register new event for dualbox check. Should be called only once.
	 * @param eventId
	 */
	public void registerEvent(int eventId)
	{
		_eventIPs.putIfAbsent(eventId, new ConcurrentHashMap<>());
	}
	
	/**
	 * @param eventId
	 * @param player
	 * @param max
	 * @return If number of all simultaneous connections from player's IP address lower than max then increment connection count and return true.<br>
	 * False if number of all simultaneous connections from player's IP address higher than max.
	 */
	public boolean tryAddPlayer(int eventId, Player player, int max)
	{
		return tryAddClient(eventId, player.getClient(), max);
	}
	
	/**
	 * @param eventId
	 * @param client
	 * @param max
	 * @return If number of all simultaneous connections from player's IP address lower than max then increment connection count and return true.<br>
	 * False if number of all simultaneous connections from player's IP address higher than max.
	 */
	public boolean tryAddClient(int eventId, GameClient client, int max)
	{
		if (client == null)
			return false; // unable to determine IP address
		
		final Map<Integer, AtomicInteger> event = _eventIPs.get(eventId);
		if (event == null)
			return false; // no such event registered
		
		final Integer addrHash = client.getConnection().getInetAddress().hashCode();
	    final AtomicInteger connectionCount = event.computeIfAbsent(addrHash, k -> new AtomicInteger());
	    int whiteListCount = Config.DUALBOX_CHECK_WHITELIST.getOrDefault(addrHash, Integer.valueOf(0)).intValue();
	    if (whiteListCount < 0 || connectionCount.get() + 1 <= max + whiteListCount)
	    {
	      connectionCount.incrementAndGet();
	      return true;
	    } 
	    
		return false;
	}
	
	/**
	 * Decreasing number of active connection from player's IP address
	 * @param eventId
	 * @param player
	 * @return true if success and false if any problem detected.
	 */
	public boolean removePlayer(int eventId, Player player)
	{
		return removeClient(eventId, player.getClient());
	}
	
	/**
	 * Decreasing number of active connection from player's IP address
	 * @param eventId
	 * @param client
	 * @return true if success and false if any problem detected.
	 */
	public boolean removeClient(int eventId, GameClient client)
	{
		if (client == null || client.getConnection() == null)
			return false; // unable to determine IP address
		
		final Map<Integer, AtomicInteger> event = _eventIPs.get(eventId);
		if (event == null)
			return false; // no such event registered
		
		final Integer addrHash = Integer.valueOf(client.getConnection().getInetAddress().hashCode());
	    return (event.computeIfPresent(addrHash, (k, v) -> (v.decrementAndGet() == 0) ? null : v) != null);
	}
	
	/**
	 * Remove player connection IP address from all registered events lists.
	 * @param client
	 */
	public void onDisconnect(GameClient client)
	{
		if ((client == null))
			return;
		
		_eventIPs.forEach((k, v) -> removeClient(k, client));
	}
	
	/**
	 * Clear all entries for this eventId.
	 * @param eventId
	 */
	public void clear(int eventId)
	{
		final Map<Integer, AtomicInteger> event = _eventIPs.get(eventId);
		if (event != null)
			event.clear();
	}
	
	/**
	 * @param player
	 * @param max
	 * @return maximum number of allowed connections (whitelist + max)
	 */
	public int getLimit(Player player, int max)
	{
		return getLimit(player.getClient(), max);
	}
	
	/**
	 * @param client
	 * @param max
	 * @return maximum number of allowed connections (whitelist + max)
	 */
	public int getLimit(GameClient client, int max)
	{
		if (client == null)
			return max;
		
		final Integer addrHash = client.getConnection().getInetAddress().hashCode();
		int limit = max;
		if (Config.DUALBOX_CHECK_WHITELIST.containsKey(addrHash))
			limit += Config.DUALBOX_CHECK_WHITELIST.get(addrHash);
		
		return limit;
	}
	
	public static AntiFeedManager getInstance()
	{
		return SingletonHolder.INSTANCE;
	}
	
	private static class SingletonHolder
	{
		protected static final AntiFeedManager INSTANCE = new AntiFeedManager();
	}
}

 

 

I use L2jMobius AntiFedd, it works perfectly in other places except in the zone

 

Register Event:


	public FarmZone(int id)
	{
		super(id);
		AntiFeedManager.getInstance().registerEvent(id);
	}
	

 

Check onEnter :

 


	@Override
	protected void onEnter(Creature character)
	{
		character.setInsideZone(ZoneId.FARM, true);
		
		if (character instanceof Player)
		{
			final Player player = (Player) character;
			
			if ((_maxPlayers > 0) && !AntiFeedManager.getInstance().tryAddPlayer(getId(), player, _maxPlayers))
			{
				player.sendPacket(new ExShowScreenMessage(player.getName() + " maximum "+ AntiFeedManager.getInstance().getLimit(player, _maxPlayers) +" connection(s) per IP address allowed.", 5000, SMPOS.TOP_CENTER, true));
				player.teleportTo(TeleportType.TOWN);
				return;
			}
			

 

 

Clear Players onExit:

 


	@Override
	protected void onExit(Creature character)
	{
		character.setInsideZone(ZoneId.FARM, false);
		
		if (character instanceof Player)
		{
			final Player player = (Player) character;
			
			AntiFeedManager.getInstance().removePlayer(getId(), player);

 

  • 0
Posted (edited)

i give you what you want in 3 lines of code but you paste all this non sense code... if all you wanna do is not having 2 players with same ip in a specific zone you should use what i pasted above. why are you using code that you don't have any clue what is doing ?

 

 

what is this line is supposed to do ?? i bet you are clueless you should start by understanding you're code , if you can't read code as machine how you expect to write it ?

final AtomicInteger connectionCount = event.computeIfAbsent(addrHash, k -> new AtomicInteger());

 

 

 

anyway if you really wanna use this system you should paste all zone lines not only exit and enter.

 

 

	public boolean tryAddClient(, GameClient client, int max)
	{
		if (client == null)
			return false; // unable to determine IP address
		
 -->> i think you're problem is related to "event" probably this is antifeed for an automatic event engine .. and probably events are registered when they are starting , you might not have any active event at the this of this time check.. man just use the 3 lines i pasted above.	
	final Map<Integer, AtomicInteger> event = _eventIPs.get(eventId);
		if (event == null)
			return false; // no such event registered
		
		final Integer addrHash = client.getConnection().getInetAddress().hashCode();
	    final AtomicInteger connectionCount = event.computeIfAbsent(addrHash, k -> new AtomicInteger());
	    int whiteListCount = Config.DUALBOX_CHECK_WHITELIST.getOrDefault(addrHash, Integer.valueOf(0)).intValue();
	    if (whiteListCount < 0 || connectionCount.get() + 1 <= max + whiteListCount)
	    {
	      connectionCount.incrementAndGet();
	      return true;
	    } 
	    
		return false;
	}
Edited by arm4729
  • 0
Posted (edited)

sry little offtopic but some1 dont have code for player limit in zone ? max clan/ally members in zone ?  acis files thx 

Edited by KejbL
  • 0
Posted (edited)

int a = 0;

for (Player player1 : World.getInstance().getPlayers())
                {

                   
                    if (player1.isInsideZone(ZoneId.YOURZONEID) && player1.getClan() == player.getClan()
                    {

                        a = a++;

                        (if a > 8){
                        player.abortAttack();
                        player.abortCast();
                        player.teleportTo(TeleportType.TOWN);
                        player.sendMessage("Clan members limit reached in this zone. You have been teleported out.")
                        }
                    }
                }

 

Edited by arm4729
  • 0
Posted (edited)

I redid my system and it is now working perfectly.

 

code :

			if (getCharacters().stream().filter(creature -> creature.getActingPlayer().getClient().getConnection().getInetAddress().getHostAddress().equals(player.getClient().getConnection().getInetAddress().getHostAddress())).count() >= 1 + _maxPlayers)
			{
				player.teleportTo(TeleportType.TOWN);
				return;
			}

 

Edited by Williams

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

    • Version 0.3.0 - NPC rendering and npcpos.txt editing https://res.cloudinary.com/h4p9pew6/video/upload/v1792026335/npc-spawns-editor.mp4   A new NPC Spawns tab. Choose an L2OFF script folder and Cruma shows the server's spawns right in the game world: - Every spawn zone is a colored outline on the geodata. From high up you also see the zones far below. - NPCs stand where the server puts them. Random spawns use the same logic as the server. - Editing: move a whole zone or its corners, add and remove corners; move and turn NPCs; change the NPC, count, respawn time, AI and its parameters; add and delete zones, makers and NPCs; rename zones and makers and every reference to a zone is updated; new zones are named after the nearest zone (for example, benon_1725_07 next to benon_1725_06). - Actions: click an NPC or a zone to open its maker; double-click to start editing; search for NPCs; the focus button flies the camera to an NPC; the View menu can hide zone outlines and keep only the NPCs. - Each client remembers its own script folder, the same way it remembers its geodata folder. - Saving: only the edited lines of npcpos.txt change; before writing, you see a diff of the changes (maximum_npc 4 -> 3); every version is kept as a dated backup.   Improvements - UI changes: small fixes and a wider tool tab.   Download Link: 0.3.0
    • Why not, if you're interested I will post an update
    • UPD: New features and improvements
    • Hi everyone! I'm the admin of Lineage 2 ByPass. Some of you might remember it from 2009, when it first launched. This year I brought it back. The old server ran on a server pack from 2008, so I didn't copy anything. Every item, shop, NPC, teleport, drop and spawn was taken from the original files and rewritten for a modern engine. The sets, farm zones, buffer and TvT are the same ones you remember, but a lot of things that had been quietly broken for years are finally fixed, and the client got a big upgrade. THE SERVER IS NOT LIVE YET. We're finishing the last pieces and plan to open the Open Beta very soon. Join our Discord to hear the date first, and to tell me what you'd change while it's still easy to change things.   ──────────────────── RATES & ENCHANT - EXP / SP x1000 - Safe enchant +6, max +25 - Scrolls: Simple 75%, Blessed 80%, Crystal 95% (from events) - Augment skill chance 6% (chance augments removed, only active/passive left); augment buffs stack and last 2 hours UPGRADED INTERFACE - Auto Farm (2 hours per day) that sweeps what you spoil, with a separate skill setup per subclass - Auto Enchant, built-in Teleport and Skill Enchant windows - Next Target (Player): a target key made for PvP - Auto Soulshots / Spiritshots and Auto Potions at a % you set - Arrows and shots never run out - Optimized game client CUSTOM GEAR — 3 TIERS OVER S GRADE - Tier 1 (+5%): Demonic weapons, Dynasty armor - Tier 2 (+10%): Epic weapons, Epic Dark Knight armor - Tier 3 (+15%): Monster weapons, Vesper Gold armor - Every tier has its own weapon ability and a set bonus by armor type - Wings, Tattoos, Custom Shields, RB Jewels GAMEPLAY - 5 subclasses; no class, subclass or Noblesse quests - No grade penalty, no weight limit - Auto Buff: a full set in one click — buffs last 2 hours, 64 buff slots - GM Shop, Custom Item Shop, Global GK EVENTS & BOSSES - Team vs Team every 2 hours — 10-minute fights, every kill counts as PvP - Olympiad every weekend, Fri–Sun 18:00–24:00 Eastern European Time, new heroes every Monday - Castle Siege (Innadril) - 3 Mini Raid Bosses (respawn every 15 minutes) and Scarlet van Halisha (every 30 minutes) And this is only the start: big features never seen in Interlude are on the way. Server location: Warsaw, Poland Website: https://l2bypass.com Discord: https://l2bypass.com/discord See you in game!
  • 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..