Jump to content
  • 0

mass create per ip


Question

Posted (edited)

hello ..i have a problem . I tried to add the code when admin create mass item only 1window per ip can receive. 
i add this: 

Spoiler

         Collection <L2PcInstance> pls = L2World.getInstance (). getAllPlayers ();
        for (L2PcInstance p: pls)
        {
               final String ip = p.getClient().getConnection().getInetAddress().getHostAddress();

                if (ips.contains(ip))
                 continue;

blablabla

but it doesnt work :/  any help ? 
code hasnt errors, just in game doesnt work :/ 

edit: i use arraylist not hash

Edited by Irrelevant

Recommended Posts

  • 0
Posted
3 minutes ago, Irrelevant said:

you said about bots ,and i had an offline shop in server ,i disconnect it and now it work.BUT i have a question, does that mean that if someone use offline shop noone else will awarded?

That was it.

No, create the next method

private boolean isClientOk(L2PcInstance player)
{
	try
	{
		player.getClient().getConnection().getInetAddress().getHostAddress();
	}
	catch (Exception e)
	{
		return false;
	}
	return true;
}

 

and then, change this line

final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();

 

to

final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers().stream().filter(p -> isClientOk(p)).collect(Collectors.toList());

 

  • Thanks 1
  • 0
Posted
4 minutes ago, melron said:

Show us the whole code

Spoiler

         List<String> ips = new ArrayList<>();
         Collection <L2PcInstance> pls = L2World.getInstance (). getAllPlayers ();
         for (L2PcInstance p: pls)
         {
               final String ip = p.getClient().getConnection().getInetAddress().getHostAddress();
                if (ips.contains(ip))
                   continue;
           p.sendMessage("Admin is rewarding all online players.");

            item = p.getInventory().addItem("Admin", id, num, null, null);
            final InventoryUpdate iu = new InventoryUpdate();
            iu.addItem(item);
            p.sendPacket(iu);
            final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
            sm.addItemName(item.getItemId());
            sm.addNumber(num);
            p.sendPacket(sm);
            i++;
            ips.add(ip);
        }
        activeChar.sendMessage("Mass-created items in the inventory of " + i + " player(s).");
        LOGGER.info("GM " + activeChar.getName() + " mass_created item Id: " + id + " (" + num + ")");
    }

 

  • 0
Posted (edited)
18 minutes ago, Irrelevant said:
  Reveal hidden contents

         List<String> ips = new ArrayList<>();
         Collection <L2PcInstance> pls = L2World.getInstance (). getAllPlayers ();
         for (L2PcInstance p: pls)
         {
               final String ip = p.getClient().getConnection().getInetAddress().getHostAddress();
                if (ips.contains(ip))
                   continue;
           p.sendMessage("Admin is rewarding all online players.");

            item = p.getInventory().addItem("Admin", id, num, null, null);
            final InventoryUpdate iu = new InventoryUpdate();
            iu.addItem(item);
            p.sendPacket(iu);
            final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
            sm.addItemName(item.getItemId());
            sm.addNumber(num);
            p.sendPacket(sm);
            i++;
            ips.add(ip);
        }
        activeChar.sendMessage("Mass-created items in the inventory of " + i + " player(s).");
        LOGGER.info("GM " + activeChar.getName() + " mass_created item Id: " + id + " (" + num + ")");
    }

 

final int id = 57;
final int num = 5000000;
final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();
final HashSet<Object> seen = new HashSet<>();
players.removeIf(e -> !seen.add(e.getClient().getConnection().getInetAddress().getHostAddress()));

players.forEach(player -> player.addItem("Admin-Reward", id, num, null, true));

activeChar.sendMessage(String.format("Mass-created items in the inventory of %s player(s)",players.size()));
LOGGER.info(String.format("GM %s mass_created item Id: %s ( %s )",activeChar.getName(),id, num));

 

If you need the number of the players who did not get the reward, you can get them by "seen.getSize()"

Edited by melron
  • 0
Posted
22 minutes ago, melron said:

final int id = 57;
final int num = 5000000;
final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();
final HashSet<Object> seen = new HashSet<>();
players.removeIf(e -> !seen.add(e.getClient().getConnection().getInetAddress().getHostAddress()));

players.forEach(player -> player.addItem("Admin-Reward", id, num, null, true));

activeChar.sendMessage(String.format("Mass-created items in the inventory of %s player(s)",players.size()));
LOGGER.info(String.format("GM %s mass_created item Id: %s ( %s )",activeChar.getName(),id, num));

 

If you need the number of the players who did not get the reward, you can get them by "seen.getSize()"

 

ja.JPG

  • 0
Posted
10 minutes ago, Irrelevant said:

i dont know what do you exactly mean ,i use dualbox to check it :/

Strange, debug it .... before the current code, add this one.

System.out.println("Players online " + L2World.getAllPlayersCount());
L2World.getInstance().getAllPlayers().forEach(p -> System.out.println(String.format("Player %s , ip %s",
		p.getName(), p.getClient().getConnection().getInetAddress().getHostAddress())));

 

and when you click mass create, check the console i need the output

  • 0
Posted
5 minutes ago, melron said:

Strange, debug it .... before the current code, add this one.


System.out.println("Players online " + L2World.getAllPlayersCount());
L2World.getInstance().getAllPlayers().forEach(p -> System.out.println(String.format("Player %s , ip %s",
		p.getName(), p.getClient().getConnection().getInetAddress().getHostAddress())));

 

and when you click mass create, check the console i need the output

you said about bots ,and i had an offline shop in server ,i disconnect it and now it work.BUT i have a question, does that mean that if someone use offline shop noone else will awarded?

  • 0
Posted (edited)
34 minutes ago, melron said:

That was it.

No, create the next method





private boolean isClientOk(L2PcInstance player)
{
	try
	{
		player.getClient().getConnection().getInetAddress().getHostAddress();
	}
	catch (Exception e)
	{
		return false;
	}
	return true;
}

 

and then, change this line





final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();

 

to





final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers().stream().filter(p -> isClientOk(p)).collect(Collectors.toList());

 

It works PERFECTLY , i add again the offline shop and test it,its working properly(no errors and reward 1char per ip)!!
Thanks dude!
P.S my code was worked too after i disconnect offline shop . but i kept yours, its better :)

Edited by Irrelevant
  • 0
Posted

I wrote you a more organized and 1 line code. (Consider i just giving you a different perspective of java). The code the other guy gave you it's good and java proof for sure but it's very messy.

 

L2World.getInstance().getPlayers().stream().filter(s -> Objects.nonNull(s.getClient().getConnection())).collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(s -> s.getClient().getConnection().getInetAddress().getHostAddress())))).forEach(s -> s.addItem(getClass().getSimpleName(), 57, 100, s, true));

 

It check for offline shops (since offline player has null connection while assigned a client)

and remove duplicate base on their host name, you can change that to IP or whatever you want.

 

I would also advice you to make a public method which retrieve the IP and the Host Name for a player

and it's safe. 

  • 0
Posted
3 minutes ago, Kara said:

I wrote you a more organized and 1 line code. (Consider i just giving you a different perspective of java). The code the other guy gave you it's good and java proof for sure but it's very messy.

 


L2World.getInstance().getPlayers().stream().filter(s -> Objects.nonNull(s.getClient().getConnection())).collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(s -> s.getClient().getConnection().getInetAddress().getHostAddress())))).forEach(s -> s.addItem(getClass().getSimpleName(), 57, 100, s, true));

 

It check for offline shops (since offline player has null connection while assigned a client)

and remove duplicate base on their host name, you can change that to IP or whatever you want.

 

I would also advice you to make a public method which retrieve the IP and the Host Name for a player

and it's safe. 

i will give a try on that .thanks :D

  • 0
Posted
1 minute ago, Irrelevant said:

i will give a try on that .thanks 😄

 

Consider this is just the way i write java. Clear and short. It doesn't mean you have to use it. 

But for sure you can experiment. (Also i believe it require java 10+)

  • 0
Posted (edited)
10 minutes ago, Kara said:

 

Consider this is just the way i write java. Clear and short. It doesn't mean you have to use it. 

But for sure you can experiment. (Also i believe it require java 10+)

if it requires above java 8 ,i will not try xd (borring to update java again,l2jfrozen uses java 6-7 XDXDXD)

Edited by Irrelevant
  • 0
Posted (edited)
6 minutes ago, Irrelevant said:

if it requires above java 8 ,i will not try xd (borring to update java again,l2jfrozen uses java 6-7 XDXDXD)

 

Ah alright then, i didn't know. For sure you should upgrade to java 8 since scripting engine is still supported and java 8 has some future proof features and it's the current stable java version.

 

I don't see the reason why you stick with Java 7 in 2021. Saying you're lazy and you spend 10 minutes writing in this topic while updating java only take 5.

 

So vouch for java 8 !

 

1X4XFqx.gif

Edited by Kara
Guest
This topic is now closed to further replies.


  • Posts

    • Yes i found it later its weird that l2off works that way level 9 it should be the top level. Is anybody who has problem with the boss Core? Because it is moving and i try to fix it
    • New arrivals: Reddit accounts Reddit SelfReg Karma Account | 20-100 POST AND COMMENT KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS: 4$ Reddit Karma Old Brute Account | 1+ KARMA | Full access with login: password:cookies: 2$ Reddit SelfReg Old Account | 1+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS: 3$ Ready Reddit accounts with karma and age for fast promotion of posts and comments! Our store’s Reddit account range includes: ➡ Reddit Karma Brute Account | 1 KARMA | Cookies access only (password may be not working) | The cheapest account | Price from: 1$ ➡ Reddit SelfReg Karma Account | 20-100 POST AND COMMENT KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS: 4$ ➡ Reddit Karma Old Brute Account | 1+ KARMA | Full access with login: password:cookies: 2$ ➡ Reddit SelfReg Old Account | 1+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS: 3$ ➡ Reddit Karma Brute Account | 20-100 POST AND COMMENT KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 5$ ➡ Reddit Karma Brute Account | 500-1000 POST AND COMMENT KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 9$ ➡ Reddit Karma Brute Account | 1000 Post Karma and 100 comment karma | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 15$ ➡ Reddit Karma Brute Account | 2000 Post Karma and 100 comment karma | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 20$ ➡ Reddit Karma Brute Account | 3000 Post Karma and 100 comment karma | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 25$ ➡ Reddit Karma Brute Account | 5000 Post Karma and 100 comment karma | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 35$ ➡ Reddit Karma Brute Account | 10000+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS (email is included and working) | Price from: 45$ ➡ Reddit Karma Brute Account | 20000 KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS (email is included and working) | Price from: 60$ ➡ Reddit Karma Brute Account | 50000+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS (email is included and working) | Price from: 90$ ➡ Reddit Karma Brute Account | 100000+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS (email is included and working) | Price from: 149$ Relevant links: Digital goods store (Website): Go Telegram bot for buying Telegram Stars: Go SMM Panel: Go – promotion of your social media accounts. Store Telegram bot: Go Promotions and special offers: 1. Promo code SEPTEMBER2025 (10% discount) for purchases in our store (Website, bot) in September! You can also use promo code for first purchase: SOCNET (15% discount) 2. Get $1 to store balance or 10-20% discount, just write your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." – you need to post it in our forum thread! 3. Get $1 for the first trial launch of SMM Panel: just open a ticket with subject “Get Trial Bonus” on our website (Support). 4. Weekly giveaways of Telegram Stars in our Telegram channel and in our star-purchase bot! News resources: ➡ Telegram channel: https://t.me/accsforyou_shop✅ ➡ WhatsApp channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n✅ ➡ Discord server: https://discord.gg/y9AStFFsrh✅ We are actively looking for suppliers for the following product positions: — Snapchat old and new accounts | With snapscores | Geo: Europe/USA | Full access via email/phone number — Reddit old accounts with post and comment karma from 100 to 100,000+ | Full access via email — LinkedIn old accounts with real connections | Geo: Europe/USA | Full access via email + active 2FA password — Instagram old accounts (2010-2023 years) | Full access via email (possibly with active 2FA password) — Facebook old accounts (2010-2023 years) | Full access via email (possibly with active 2FA password) | With or without friends | Geo: Europe/USA/Asia — Threads accounts | Full access via email (possibly with active 2FA password) — TikTok/Facebook/Google ADS Agency advertising accounts Contact us below — let’s discuss terms! We are always open to other partnership offers as well. Contacts and support: ➡ Telegram: https://t.me/socnet_support✅ ➡ WhatsApp: https://wa.me/79051904467✅ ➡ Discord: socnet_support ✅ ➡ ✉ Email: solomonbog@socnet.store ✅ Also via these contacts you can: — get consultation on bulk purchases — establish partnership (current partners: https://socnet.bgng.io/partners) — become our supplier SocNet — store of digital goods and premium subscriptions ✅
    • New arrivals: Reddit accounts Reddit SelfReg Karma Account | 20-100 POST AND COMMENT KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS: 4$ Reddit Karma Old Brute Account | 1+ KARMA | Full access with login: password:cookies: 2$ Reddit SelfReg Old Account | 1+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS: 3$ Ready Reddit accounts with karma and age for fast promotion of posts and comments! Our store’s Reddit account range includes: ➡ Reddit Karma Brute Account | 1 KARMA | Cookies access only (password may be not working) | The cheapest account | Price from: 1$ ➡ Reddit SelfReg Karma Account | 20-100 POST AND COMMENT KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS: 4$ ➡ Reddit Karma Old Brute Account | 1+ KARMA | Full access with login: password:cookies: 2$ ➡ Reddit SelfReg Old Account | 1+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS: 3$ ➡ Reddit Karma Brute Account | 20-100 POST AND COMMENT KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 5$ ➡ Reddit Karma Brute Account | 500-1000 POST AND COMMENT KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 9$ ➡ Reddit Karma Brute Account | 1000 Post Karma and 100 comment karma | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 15$ ➡ Reddit Karma Brute Account | 2000 Post Karma and 100 comment karma | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 20$ ➡ Reddit Karma Brute Account | 3000 Post Karma and 100 comment karma | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 25$ ➡ Reddit Karma Brute Account | 5000 Post Karma and 100 comment karma | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS | Price from: 35$ ➡ Reddit Karma Brute Account | 10000+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS (email is included and working) | Price from: 45$ ➡ Reddit Karma Brute Account | 20000 KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS (email is included and working) | Price from: 60$ ➡ Reddit Karma Brute Account | 50000+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS (email is included and working) | Price from: 90$ ➡ Reddit Karma Brute Account | 100000+ KARMA | MIX IP Registered | FORMAT: USERNAME: PASSWORD:EMAIL:MAILPASS (email is included and working) | Price from: 149$ Relevant links: Digital goods store (Website): Go Telegram bot for buying Telegram Stars: Go SMM Panel: Go – promotion of your social media accounts. Store Telegram bot: Go Promotions and special offers: 1. Promo code SEPTEMBER2025 (10% discount) for purchases in our store (Website, bot) in September! You can also use promo code for first purchase: SOCNET (15% discount) 2. Get $1 to store balance or 10-20% discount, just write your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." – you need to post it in our forum thread! 3. Get $1 for the first trial launch of SMM Panel: just open a ticket with subject “Get Trial Bonus” on our website (Support). 4. Weekly giveaways of Telegram Stars in our Telegram channel and in our star-purchase bot! News resources: ➡ Telegram channel: https://t.me/accsforyou_shop✅ ➡ WhatsApp channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n✅ ➡ Discord server: https://discord.gg/y9AStFFsrh✅ We are actively looking for suppliers for the following product positions: — Snapchat old and new accounts | With snapscores | Geo: Europe/USA | Full access via email/phone number — Reddit old accounts with post and comment karma from 100 to 100,000+ | Full access via email — LinkedIn old accounts with real connections | Geo: Europe/USA | Full access via email + active 2FA password — Instagram old accounts (2010-2023 years) | Full access via email (possibly with active 2FA password) — Facebook old accounts (2010-2023 years) | Full access via email (possibly with active 2FA password) | With or without friends | Geo: Europe/USA/Asia — Threads accounts | Full access via email (possibly with active 2FA password) — TikTok/Facebook/Google ADS Agency advertising accounts Contact us below — let’s discuss terms! We are always open to other partnership offers as well. Contacts and support: ➡ Telegram: https://t.me/socnet_support✅ ➡ WhatsApp: https://wa.me/79051904467✅ ➡ Discord: socnet_support ✅ ➡ ✉ Email: solomonbog@socnet.store ✅ Also via these contacts you can: — get consultation on bulk purchases — establish partnership (current partners: https://socnet.bgng.io/partners) — become our supplier SocNet — store of digital goods and premium subscriptions ✅
    • Vibe SMS simple and user-friendly We’re building a service where it’s important not only that everything works, but also that it’s convenient and stress-free for you. With Vibe SMS, there’s no unnecessary fuss or complicated rules — just a reliable platform and support when you need it. Here, you’re not just a user; you’re part of a team that values honesty, trust, and convenience for everyone Our website: https://vibe-sms.net/ Our Telegram channel: https://t.me/vibe_sms        
    • Same account Shillien Knight lvl 57 , AVADON HEAVY SET , JEWLERY B. Prophet lvl 57 , C grade armor. I sell both because on same email , different subaccounts   190E  
  • 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