scraw Posted April 28, 2020 Posted April 28, 2020 (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 April 28, 2020 by scraw Quote
EdithFinch Posted May 14, 2020 Posted May 14, 2020 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 } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.