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
  • Upvote 1

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

    • https://www.4shared.com/s/fyGGySJVvfa  
    • PAYPAL& BINANCE PAYPAL& BINANCE
    • SOCNET STORE — is a unique place where you can find everything you need for your work on the Internet!   We offer the following range of products and services: Verified accounts with blue tick marks and confirmed documents in Instagram, Facebook, Twitter (X), LinkedIn; Gift cards and premium subscriptions for your services (Instagram Meta, Facebook Meta, Discord Nitro, Telegram Premium, YouTube Premium, Spotify Premium, ChatGPT, Netflix Premium, LinkedIn Premium, Twitter Premium, etc.); Telegram bot for purchasing Telegram Stars with a minimum markup with automatic delivery; Replenishment of your advertising accounts (in TikTok ADS, Facebook ADS, Google ADS, Bing ADS) + linking a bank card; Payment for any other service or subscription with a markup from 5 to 25% (depending on the cost of the subscription) Available payment methods: via PayPal, any cryptocurrency (+Binance Pay), Telegram Stars, Cash App, or any bank card.    Our online store  SOCNET.STORE  Our Telegram Stars Bot  SOCNET.CC  Our SMM-Panel for social media promotion  SOCNET.PRO  Telegram store  SOCNET.SHOP    News:  ➡ Telegram channel ➡ WhatsApp channel ➡ Discord server  Contacts and support:  ➡ Telegram support ➡ WhatsApp support ➡ Discord support: socnet_support ➡ Email support: solomonbog@socnet.store We have been operating for a long time and have gathered a huge list of reviews about our work! Our large list of positive and honest reviews is presented on our website!   VERIFIED ACCOUNTS    Verified old Instagram Meta account (2010-2020) with an active blue checkmark | Subscription has already been paid for 1 month in advance, account confirmed by documents: from $70 Verified old Facebook Meta account (2010-2023) with an active blue checkmark | Subscription has already been paid for 1 month in advance, account confirmed by documents: from $70 Verified Linkedin account (2010-2024) with an active checkmark and confirmed documents | Checkmark does not require renewal: from $80 Verified old Twitter (X) account (2010-2022) with an active blue checkmark | GEO: Tier 1-3 (your choice) | Subscription has already been paid for 1 month in advance: from $16    TELEGRAM STARS    Telegram Stars | 1 star from $0.0175 | Discounts for bulk orders | Delivery within 1-2 minutes automatically    GIFT SERVICES & PREMIUM SUBSCRIPTIONS  DISCORD NITRO Discord Nitro Classic (Basic) GIFT | 1/12 MONTHS | NO LOGIN OR PASSWORD NEEDED | Full subscription guarantee | Price from: $3.15 Discord Nitro FULL | 1/12 MONTHS | NO LOGIN OR PASSWORD NEEDED | Full subscription guarantee | Price from: $6.8 SPOTIFY PREMIUM Individual Spotify Premium plan for 1 month ON YOUR ACCOUNT | Available worldwide | Price from: $2.49 Family Spotify Premium plan for 1 month ON YOUR ACCOUNT | Works in any country | Price from: $3.75 Personal YouTube Premium Music on your account | 1 month | Ad-free YouTube | Price from: $3.75 Family YouTube Premium Music on your account | 1 month | Ad-free YouTube | Price from: $4.35 TELEGRAM PREMIUM Telegram Premium subscription for 1 month on your account | Authorization required (via TDATA or phone number) | Price from: $6 Telegram Premium subscription for 3 months on your account | No account authorization required | Guaranteed for full period | Price from: $17 Telegram Premium subscription for 6 months on your account | No account authorization required | Guaranteed for full period | Price from: $22 Telegram Premium subscription for 12 months on your account | No account authorization required | Guaranteed for full period | Price from: $37 GOOGLE VOICE • Google Voice Accounts (GMAIL US NEW) | Age/Year: Random 2024 | Phone Verified: Yes | Price from: $13 TWITTER(X) PREMIUM • Twitter Premium X subscription on your Twitter account for 1 month/1 year (your choice). Authorization in your Twitter account is required. Price from: $13 per month • Twitter X Premium Plus subscription with GROK AI on your Twitter account for 1 month/1 year (your choice). Authorization in your Twitter account is required. Price from: $55 NETFLIX PREMIUM • Netflix Premium subscription for 1 month on your personal account for any country, renewable after expiration | Price from: $10 CANVA PRO • CANVA PRO subscription for 1 month via invitation to your email | Price from: $1 CHATGPT 5 • Shared ChatGPT 5 Plus account FOR 2/5 USERS | Price from: $5 / $10 • Group ChatGPT 5 Plus subscription on your own email address for 1 month | Price from: $5 • Personal ChatGPT 5 Plus account FOR 1 USER or CHAT GPT PLUS subscription on your own account | Price from: $18 • ChatGPT 5 PRO account with UNLIMITED REQUESTS | Dedicated personal account FOR 1 USER ONLY or ON YOUR ACCOUNT | Works in any country or region | Price from: $220 Payment for any other subscription and replenishment of advertising accounts: Additional 5–20% to the cost of the subscription on the site or to the replenishment amount depending on the total purchase amount.   Attention: This text block does not represent our full product range; for more details, please visit the relevant links below! If you have any questions, our support team is always ready to help!       Our online store  SOCNET.STORE  Our Telegram Stars Bot  SOCNET.CC  Our SMM-Panel for social media promotion  SOCNET.PRO  Telegram store  SOCNET.SHOP    News:  ➡ Telegram channel ➡ WhatsApp channel ➡ Discord server  Contacts and support:  ➡ Telegram support ➡ WhatsApp support ➡ Discord support: socnet_support ➡ Email support: solomonbog@socnet.store We have been operating for a long time and have gathered a huge list of reviews about our work! Our large list of positive and honest reviews is presented on our website!  10% – 20% Discount or $1 BONUS for your registration  If you’d like to receive a $1 BONUS for your registration OR a DISCOUNT of 10% – 20% on your first purchase, simply leave a comment: "SEND ME MY BONUS, MY USERNAME IS..." You can also use the ready promo code across all our stores: "SOCNET" (15% discount!)  We invite you to COOPERATE and EARN with us  Want to sell your product or service in our stores and earn money? Want to become our partner or propose a mutually beneficial collaboration? You can contact us through the CONTACTS listed in this thread. Frequently Asked Questions and Refund Policy If you have any questions or issues, our fast customer support is always ready to respond to your requests! Refunds for services that do not fully meet the stated requirements or quality will only be issued if a guarantee and duration are explicitly mentioned in the product description. In all other cases, refunds will not be fully processed! By purchasing such services, you automatically agree to our refund policy for non-provided services. We currently accept CRYPTOMUS, Payeer, NotPayments, Perfect Money, Russian and Ukrainian bank cards, AliPay, BinancePay, CryptoBot, credit cards, and PayPal. The $1 registration bonus can only be used for purchases and only once after your first registration in any SOCNET project. We value every customer and provide replacements in case of invalid accounts through our contact methods! p.s.: Purchase bonuses can be used across any SOCNET projects: web store or Telegram bots.
  • 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