Jump to content

Recommended Posts

Posted (edited)

-Hello..i know that noone will answer but i never stop hopping..so get to the point:

 

 

-I have an code for auto-reward every shcelude time "X" but it reward all players in L2World no matter if dualbox or whatever.

-That i want is: Players reward by Ip (only one player) 

 

thats what i have :

Spoiler

 L2JFROZEN REV 1132!!!!\i want to do it individual code:

==============================================
 public static void AutoReward ()
 {
 Collection <L2PcInstance> pls = L2World.getInstance (). getAllPlayers ();
 for (L2PcInstance p: pls)
 {
 p.sendMessage ("AutoReward: You got" + Config.AUTO_REWARD_COUNT + "" + Config.NAME_ITEM_REWARD + "by being online");
 p.getInventory (). addItem ("", Config.AUTO_REWARD_ID, Config.AUTO_REWARD_COUNT, p, null);
}
}

}

 

Edited by scraw
  • 3 weeks later...
Posted
final Map<String, AtomicInteger> IP = new HashMap<>();
		
for (final L2PcInstance activeChar : L2World.getInstance().getPlayers())
{
	if (IP.computeIfAbsent(activeChar.getIPAddress(), k -> new AtomicInteger()).incrementAndGet() > MAX_REWARD_PER_IP) // MAX_REWARD_PER_IP represent a static var or a config of yours.
	{
        // Skip player since there are more IP's in map than allowed
		continue;
	}
    
    // Your code for reward
}

 

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


×
×
  • 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..