Jump to content

Question

Posted (edited)

-Hello once again . I have an issue:

-I have found a code for Newbie zone depends by level but i want to depends by echant of amor/weapon/jewel (no more than +6)

also getflag on enter and setflag(0) on exit.

\

 

Code:

Spoiler

    protected void onEnter (final L2Character character)
    {
        if (character instanceof L2PcInstance)
        {
            if ((((L2PcInstance) character) .isNewbie ()))
            {
                ((L2PcInstance) character) .sendMessage ("You entered the Newbie Zone.");
                ((L2PcInstance) character) .sendMessage ("This area is protected up to level" + Config.MAX_LEVEL_NEWBIE_STATUS + ", from level" + (Config.MAX_LEVEL_NEWBIE_STATUS + 1) + "the player who attempts to enter will be removed from the area . ");
            }
        }
            else

 

Spoiler

    protected void onExit (final L2Character character)
    {
        ((L2PcInstance) character) .sendMessage ("You left the Newbie Zone.");
    }

 

Edited by scraw

Recommended Posts

  • 1
Posted (edited)

You can do it by FuncEnchant , keep player items , and calculate their status for a specific enchant level(like max olympiad enchant) 

Edit the isInsideZone(ZONE_PVP) to your needs

int maxZoneEnchant = 6;	
		if (env.player != null && env.player instanceof L2PcInstance)
		{
			final L2PcInstance player = (L2PcInstance) env.player;
			if (player.isInsideZone(ZONE_PVP) && maxZoneEnchant >= 0 && (enchant + overenchant) > maxZoneEnchant)
			{
				if (maxZoneEnchant > 3)
				{
					overenchant = maxZoneEnchant - 3;
				}
				else
				{
					overenchant = 0;
					enchant = maxZoneEnchant;
				}
			}
		}

 

Edited by @IcathiaLord
  • Thanks 1
  • Upvote 1
  • 0
Posted
if (character instanceof Player)
{
	final Player player = (Player) character;
	final ItemInstance item = player.getInventory().getItems().stream().filter(item -> item.getEnchantLevel() > 6 && item.isEquipped()).findFirst().orElse(null);
	if (item != null)
	{
		player.sendMessage(String.format("Maximum enchant in this zone +6. You can't use the item %s", item.getName()));
		// Handle telportation here
	}
}

This code is written in acis. adapt it with the proper method names to fit on frozen

Note: You MUST handle the equip case when the player is already in the zone. onEnter is not enough for this kind of feature

  • 0
Posted (edited)

you have to edit atleast 2 places to prevent ppl from entering or equipping items in zones

 

you can add this in l2pcinstance/playerinstance and use it anywhere

 


    public boolean hasEnchantedItems()
    {
        return getInventory().getItems().stream().filter(item -> item.getEnchantLevel() > 6 && item.isEquipped()).findFirst().orElse(null) != null;
    }

 

like

 

if(player.hasEnchantedItems())
{
 // preventation
 return;
}

Edited by BruT
  • 0
Posted (edited)
53 minutes ago, melron said:

if (character instanceof Player)
{
	final Player player = (Player) character;
	final ItemInstance item = player.getInventory().getItems().stream().filter(item -> item.getEnchantLevel() > 6 && item.isEquipped()).findFirst().orElse(null);
	if (item != null)
	{
		player.sendMessage(String.format("Maximum enchant in this zone +6. You can't use the item %s", item.getName()));
		// Handle telportation here
	}
}

This code is written in acis. adapt it with the proper method names to fit on frozen

Note: You MUST handle the equip case when the player is already in the zone. onEnter is not enough for this kind of feature

i'll try

 

53 minutes ago, BruT said:

you have to edit atleast 2 places to prevent ppl from entering or equipping items in zones

how do so ?

Edited by scraw
  • 0
Posted (edited)

edited above.

 

the one must be in enterZone the other in UseItem.java somewhere

 

preventation is up to your imagination

Edited by BruT
  • 0
Posted
53 minutes ago, melron said:

if (character instanceof Player)
{
	final Player player = (Player) character;
	final ItemInstance item = player.getInventory().getItems().stream().filter(item -> item.getEnchantLevel() > 6 && item.isEquipped()).findFirst().orElse(null);
	if (item != null)
	{
		player.sendMessage(String.format("Maximum enchant in this zone +6. You can't use the item %s", item.getName()));
		// Handle telportation here
	}
}

This code is written in acis. adapt it with the proper method names to fit on frozen

Note: You MUST handle the equip case when the player is already in the zone. onEnter is not enough for this kind of feature

java 1.7 please

 

52 minutes ago, BruT said:

you have to edit atleast 2 places to prevent ppl from entering or equipping items in zones

 

you can add this in l2pcinstance/playerinstance and use it anywhere

 


    public boolean hasEnchantedItems()
    {
        return getInventory().getItems().stream().filter(item -> item.getEnchantLevel() > 6 && item.isEquipped()).findFirst().orElse(null) != null;
    }

 

like

 

 


if(player.hasEnchantedItems())
{
 // preventation
}

 

so , im sorry but where exactly i add those lines?

  • 0
Posted (edited)
2 minutes ago, zemaitis said:

What's the point in checking if player has enchanted over +6 items during teleport? What if they teleport to zone and enchant items there?

i want to activate this to a teleport for newbies and prevent unfair pvp's (there will be no shops or towns nearby )

Edited by scraw
  • 0
Posted
1 minute ago, scraw said:

i want to activate this to a teleport for newbies and prevent unfair pvp's (there will be no shops or towns nearby )

But they can bring enchant scrolls and weapons there and enchant

  • 0
Posted (edited)
21 minutes ago, zemaitis said:

But they can bring enchant scrolls and weapons there and enchant

thats why melron says checkinvetory ..

 

45 minutes ago, BruT said:

edited above.

 

the one must be in enterZone the other in UseItem.java somewhere

 

preventation is up to your imagination

i have already these lines in l2pcinstance

Spoiler

    public int getItemCount(final int itemId, final int enchantLevel)
    {
        return _inventory.getInventoryItemCount(itemId, enchantLevel);
    }

is that u meant?

 

52 minutes ago, BruT said:

you have to edit atleast 2 places to prevent ppl from entering or equipping items in zones

 

you can add this in l2pcinstance/playerinstance and use it anywhere

 


    public boolean hasEnchantedItems()
    {
        return getInventory().getItems().stream().filter(item -> item.getEnchantLevel() > 6 && item.isEquipped()).findFirst().orElse(null) != null;
    }

 

like

 


if(player.hasEnchantedItems())
{
 // preventation
 return;
}

ok i understand what u mean..but this code is writen with 1.8 and i have 1.7 so many erros come out

Edited by scraw
  • 0
Posted (edited)

Hello, It's me ! (kidding)

 

@scraw Double or triple posts/replies are not allowed . Please read the forum rules. You can use your edit button.

 

Thanks.

Edited by Justice
  • 0
Posted
2 minutes ago, Justice said:

Hello, It's me ! (kidding)

 

@scraw Double or triple posts/replies are not allowed . Please read the forum rules. You can use your edit button.

 

Thanks.

oh ok .apologies u can delete the first replies .

  • 0
Posted (edited)

to be honest your idea is abit crappy and old, the best version of this mod is to set players enchantent to max +6 when they enter a specific zone, its abit more complicated but its way better. i thin there are such shares somewhere in the forum.

Edited by BruT
  • 0
Posted (edited)
On 4/29/2020 at 4:23 PM, @IcathiaLord said:

You can do it by FuncEnchant , keep player items , and calculate their status for a specific enchant level(like max olympiad enchant) 

Edit the isInsideZone(ZONE_PVP) to your needs


int maxZoneEnchant = 6;	
		if (env.player != null && env.player instanceof L2PcInstance)
		{
			final L2PcInstance player = (L2PcInstance) env.player;
			if (player.isInsideZone(ZONE_PVP) && maxZoneEnchant >= 0 && (enchant + overenchant) > maxZoneEnchant)
			{
				if (maxZoneEnchant > 3)
				{
					overenchant = maxZoneEnchant - 3;
				}
				else
				{
					overenchant = 0;
					enchant = maxZoneEnchant;
				}
			}
		}

 

thanks i think this will save me ..i go test! .but  because isn't pvp zone ( its completely new zone only for newbies) i need and auto-flag on enter and noflag on exit :/ i try to copy paste the autoflag from pvpzone but didnt work properly and have some errors :/.

 

 

* I Tried that but i have multiple errors idk why i delete onEnter via level and i paste above ifinsidezone and your code ,i try to adapt for l2jfrozen but everything i change become one more error :/

Edited by scraw
  • 0
Posted (edited)

The code i provided must be placed at skills.funcs.FucnEnchant.java , i took same code as OlyMaxEnchant from l2jfrozen 1132 , and just changed to your needs .

Change player.isInsideZone(ZONE_PVP) to (ZONE_NEWBIE) or whatever you named , and the enchant will take effect if you are inside this zone .

For onEnter flag you just edit the zone.type.NewbieZone.java method and done.

Edited by @IcathiaLord
Guest
This topic is now closed to further replies.
×
×
  • Create New...