• 0
Sign in to follow this  
l2jkain

Help TownManager aCis

Question

l2jkain    1

Hi, I'm adapting the Town Manager event for aCis. 

When I change this TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(true);

 

for 

ZoneManager.getInstance().getZoneById(i, TownZone.class).setIsTWZone(true);

 

generates the error

 

GSyA0X0.png

 

what did I do wrong ?

 

TownManager of jserver :

 

public static final L2TownZone getTown(int townId)
    {
        for (L2TownZone temp : ZoneManager.getInstance().getAllZones(L2TownZone.class))
        {
            if (temp.getTownId() == townId)
            {
                return temp;
            }
        }
        return null;
    }
    
    /**
     * Returns the town at that position (if any)
     * @param x
     * @param y
     * @param z
     * @return
     */
    public static final L2TownZone getTown(int x, int y, int z)
    {
        for (L2ZoneType temp : ZoneManager.getInstance().getZones(x, y, z))
        {
            if (temp instanceof L2TownZone)
            {
                return (L2TownZone) temp;
            }
        }
        return null;
    }

Share this post


Link to post
Share on other sites

6 answers to this question

  • 0
l2jkain    1
6 minutes ago, melron said:

TownWarManager:106

 

106 

 

this TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(true);

 

for 

ZoneManager.getInstance().getZoneById(i, TownZone.class).setIsTWZone(true);

Edited by l2jkain

Share this post


Link to post
Share on other sites
  • 0
melron    66

what is 'i'? 

 

you could use a null check first...

final TownZone tempZone = ZoneManager.getInstance().getZoneById(i, TownZone.class);
if (tempZone != null)
	tempZone.setIsTWZone(true);
else
	System.out.println("Zone not found with id " + i);

 

Share this post


Link to post
Share on other sites
  • 0
l2jkain    1
12 minutes ago, melron said:

what is 'i'? 

 

you could use a null check first...


final TownZone tempZone = ZoneManager.getInstance().getZoneById(i, TownZone.class);
if (tempZone != null)
	tempZone.setIsTWZone(true);
else
	System.out.println("Zone not found with id " + i);

 

 


 

I created a check in ZoneManager for all town zones and it worked perfectly,

this should work.

ZoneManager.getInstance (). GetZoneById (i, TownZone.class) .setIsTWZone (true)

I created this in ZoneManager


public TownZone getTown (int townId)
{
for (TownZone temp: ZoneManager.getInstance (). getAllZones (TownZone.class))
{
if (temp.getTownId () == townId)
return temp;
}
return null;
}

 

   

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.