Jump to content
  • 0

prohibit dualbox IP or HWID onEnter zone


Question

Posted (edited)

Hello guys. I am looking for code/line that prohibit dualbox inside a zone ..
Like when player enter in a Zone (L2RaidBoss as example) check Ip or HWID and not allow to a second char to enter and teleport back ..

Spoiler

    protected void onEnter(final L2Character character)
    {
        if (_enabled)
        {
            if (character instanceof L2PcInstance)
            {
                // Thread.dumpStack();
                L2PcInstance player = (L2PcInstance) character;
                
                if (player.isGM() || Config.ALLOW_DIRECT_TP_TO_BOSS_ROOM)
                {
                    player.sendMessage("You entered " + _zoneName);

 

Thank you in advance
Edit: i just see one more guy just LF that aswell (i guess perfect timming)

L2jfrozen 1132. java 7

Edited by scraw

15 answers to this question

Recommended Posts

  • 0
Posted (edited)
@Override
	protected void onEnter(final L2Character character)
	{
		if (character instanceof L2PcInstance)
		{
			final L2PcInstance player = character.getActingPlayer();
			if (L2World.getInstance().getAllPlayers().stream().filter(p->p.isInsideZone(L2Character.ZONE_PEACE) && p.getIpAddress()!=null && p.getIpAddress().equals(player.getIpAddress())).count() > 0)
			{
				player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
				return;
			}
			player.setInsideZone(L2Character.ZONE_PEACE, true);
		}
	}

Instead of zone_peace you should put your desired zone. Also in L2PcInstance

 

public String getIpAddress()
	{
		if (getClient()==null)
			return null;
		
		return getClient().getConnection().getInetAddress().getHostAddress();
	}

 

 

Edited by Zake
  • 0
Posted

@Zake thanks for reply.. i just need this line to java 1.7 
 

Spoiler

 if (L2World.getInstance().getAllPlayers().stream().filter(p>p.isInsideZone(L2Character.ZONE_PEACE) && p.getIpAddress()!=null && p.getIpAddress().equals(player.getIpAddress())).count() > 0)
 

 

  • 0
Posted (edited)
15 minutes ago, scraw said:

@Zake thanks for reply.. i just need this line to java 1.7 
 

  Hide contents

 if (L2World.getInstance().getAllPlayers().stream().filter(p>p.isInsideZone(L2Character.ZONE_PEACE) && p.getIpAddress()!=null && p.getIpAddress().equals(player.getIpAddress())).count() > 0)
 

 

Lel i though java streams were introduced in java 7. nvm

 

@Override
	protected void onEnter(final L2Character character)
	{
		if (character instanceof L2PcInstance)
		{
			final L2PcInstance player = character.getActingPlayer();
			int count=0;
			for (L2PcInstance p : L2World.getInstance().getAllPlayers())
			{
				if (p == null || p.getIpAddress() ==null || p.getObjectId() == player.getObjectId() || !p.isInsideZone(L2Character.ZONE_PEACE) || p.getIpAddress()!= player.getIpAddress())
					continue;
				
				count++;
			}
			if (count > 0)
			{
				player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
				return;
			}
			player.setInsideZone(L2Character.ZONE_PEACE, true);
		}
	}

 

Edited by Zake
  • 0
Posted
8 minutes ago, scraw said:

@Zakecode has no error (i havent build yet) i just cant find what zone is the bosszone ..i go to l2character and there is no boss_zone :/

If there is not you should create one.

  • 0
Posted
Just now, Zake said:

If there is not you should create one.

im my zones.xml is BossZone ..but ZONE_BOSS or BOSS_ZONE isnt working  :/ in L2Character isnt that zone at all..any way i will insert into another zone to check and if it works i will find the way (i think)

@Zake https://ibb.co/XJd6H6h

  • 0
Posted (edited)
4 hours ago, scraw said:

im my zones.xml is BossZone ..but ZONE_BOSS or BOSS_ZONE isnt working  :/ in L2Character isnt that zone at all..any way i will insert into another zone to check and if it works i will find the way (i think)

@Zake https://ibb.co/XJd6H6h

 

The error is very clearly. An object of type L2ChestInstance cannot be casted as L2PcInstance.

Java basically is trying to cast a furniture as a human. It's not same type therefore you get this error.

 

5 hours ago, Zake said:






@Override
	protected void onEnter(final L2Character character)
	{
		if (character instanceof L2PcInstance)
		{
			final L2PcInstance player = character.getActingPlayer();
			if (L2World.getInstance().getAllPlayers().stream().filter(p->p.isInsideZone(L2Character.ZONE_PEACE) && p.getIpAddress()!=null && p.getIpAddress().equals(player.getIpAddress())).count() > 0)
			{
				player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
				return;
			}
			player.setInsideZone(L2Character.ZONE_PEACE, true);
		}
	}

 

 

And no this is not how you use count() or isPresent(). 

 

You need to read the documentations of newer java versions and their methods. 

 

anyMatch will quit after it find an element. isPresent() and count() iterates the whole stream and cause further delay for no reason.

 

L2World.getInstance().getPlayers().stream().anyMatch(s -> s.getIPAddress() == target.getIPAddress());

 

In addition why go though all L2World players and not simply the one contained in zone?

 

Also you don't need to check for null... both equal and == does a null check like instanceof 

 

@scraw Install java 8. You don't need any special engine to parse external java files or py. We live in 2021. JDK 7 is banned.

 

 

Edited by Kara
  • 0
Posted
9 hours ago, Kara said:

 

The error is very clearly. An object of type L2ChestInstance cannot be casted as L2PcInstance.

Java basically is trying to cast a furniture as a human. It's not same type therefore you get this error.

 

 

there is a check which he apparently missed

if (character instanceof L2PcInstance)

so there is no need to count furnitures

 

9 hours ago, Kara said:

And no this is not how you use count() 

 

If you are referring to Collectors.counting() this is the exact same way to count elements in a stream. There are also 5(+?) more ways, none of them makes an actual difference

9 hours ago, Kara said:

In addition why go though all L2World players and not simply the one contained in zone?

You have to store them upon enter/remove upon exit .If this guy wants to create 100 raid(custom?) zones, there would be like 100 concurrent maps/lists(whatever he wants to use) in memory, unfortunately most of them empty. This is still a faster road for a cpu though (especially for high player counts), but almost redundant.

9 hours ago, Kara said:

Also you don't need to check for null

 

this is indeed unnecessary, my apologies

  • 0
Posted
13 minutes ago, Zake said:

 

You have to store them upon enter/remove upon exit .If this guy wants to create 100 raid(custom?) zones, there would be like 100 concurrent maps/lists(whatever he wants to use) in memory, unfortunately most of them empty. This is still a faster road for a cpu though (especially for high player counts), but almost redundant.

Doesn't frozen have getPlayersInside/getCharactersInside method? :yeih:

  • 0
Posted
3 minutes ago, melron said:

Doesn't frozen have getPlayersInside/getCharactersInside method? :yeih:

Oh my apologies too then, i didn't expect that frozen would store them. 

  • Haha 1
  • 0
Posted
1 minute ago, Zake said:

Oh my apologies too then, i didn't expect that frozen would store them. 

To be honest, i didn't too... :P

  • 0
Posted (edited)

When a person is telling you that anyMatch iterate until it find an element while yours keep busy the stream until all elements scanned and your logic is "It works so it's fine" then OK

Edited by Kara
  • 0
Posted
16 minutes ago, Kara said:

When a person is telling you that anyMatch iterate until it find an element while yours keep busy the stream until all elements scanned and your logic is "It works so it's fine" then OK

Lol, i NEVER said that anyMatch() or count() do not iterate through all the elements of a stream. I also never said that this is the optimal way to do, this was just a quick example written in np++ using just a method of l2jfrozen's svn.

  • 0
Posted
6 minutes ago, Zake said:

Lol, i NEVER said that anyMatch() or count() do not iterate through all the elements of a stream. I also never said that this is the optimal way to do, this was just a quick example written in np++ using just a method of l2jfrozen's svn.

 

wkM3q6E.gif

  • 0
Posted
5 minutes ago, Kara said:

 

wkM3q6E.gif

Still never said any of these 2, you may read the posts above and confirm on your own. Nevermind topic locked

  • Thanks 1
Guest
This topic is now closed to further replies.


  • Posts

    • Dear friends, right now we are holding a grand competition with a prize fund of more than $ 1000 in our stores https://socnet.store , telegram store: https://socnet.shop and SMM panel: https://socnet.pro There are more than 50 prize places in our competition, each lucky person can take one of the places. Important condition: you must make a purchase at any time before June 1, 2025. The more purchases you make - the more chances you have to win the main prize in the community of $ 300! ➡ Our Online Shop: socnet.store  ➡ Our SMM-Boosting Panel: socnet.pro  ➡ Telegram Shop Bot: socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: 79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
    • Dear friends, right now we are holding a grand competition with a prize fund of more than $ 1000 in our stores https://socnet.store , telegram store: https://socnet.shop and SMM panel: https://socnet.pro There are more than 50 prize places in our competition, each lucky person can take one of the places. Important condition: you must make a purchase at any time before June 1, 2025. The more purchases you make - the more chances you have to win the main prize in the community of $ 300! ➡ Our Online Shop: socnet.store  ➡ Our SMM-Boosting Panel: socnet.pro  ➡ Telegram Shop Bot: socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: 79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
    • REBORN ETERNAL IL x10 WTS  1gb 8e (a lot in stock) DR set +6 180e Frintezza+6 200e Zaken+6 200e AQ+6 200e You must go first or Pufa middleman service
    • There's many reasons why it would be more NO than YES : Using NCSoft assets is a death wish, they can lawyer any LU3/Unity if they wanted, since it's a plain steal of intellectual property. It's an hobby, as you said it, and it's not specially about money. Money is a way to filter idiots/resellers, nothing more. It's really about trying to replicate old content and optimize it which I find it fun. I just align with the basic idea than an emulator emulates. When you launch Project64 and SuperMario 64, you don't expect to get something more than 120 stars and Bowser boss in the end - which should have been L2J project to begin with Even if I played a lot with TESCS from Morrowind, back in time, it's not enough to handle current engines, and I'm too lazy to learn Unity/Unreal Engine. Moreover, it would mean buying assets. While doing it alone would be a fail, coupling to L2J / L2 community would still be shitty (since the majority is RU/BR) ; people is only about fame/glory/reselling shit on back of others. Opening to others, the project would be leaked day 1, rebranded and resold. MMO genre is basically dead, and that's not a reboot of any game (l2/wow classic :D) which will turn the tide. Regarding L2 or an remastered version of it, you can obviously blatantly copy-cat it (as Propnight did for Dead by daylight).   All frenchies aren't supposed to do Expedition 33 :).
    • 190euro until last month, don't miss it.
  • 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