Jump to content

Question

Posted

i have this error and i dont have any idea how i can fix it  can some one help 

error : https://ibb.co/qdLj1L4

 

code :   

---------------------------------------------------------------------------------------------------------------------------------------------------------
package zones;

import java.util.concurrent.ScheduledFuture;

import l2f.commons.threading.RunnableImpl;
import l2f.gameserver.ThreadPoolManager;
import l2f.gameserver.listener.zone.OnZoneEnterLeaveListener;
import l2f.gameserver.model.Creature;
import l2f.gameserver.model.Player;
import l2f.gameserver.model.Zone;
import l2f.gameserver.scripts.ScriptFile;
import l2f.gameserver.utils.ReflectionUtils;

/**
 * @author L2Mythras
 */

public class PvPZone implements ScriptFile
{
    private static ZoneListener _zoneListener;

    @Override
    public void onLoad()
    {
        _zoneListener = new ZoneListener();
        Zone zone = ReflectionUtils.getZone("[pvp_zone_toi]");
        zone.addListener(_zoneListener);
    }

    @Override
    public void onReload()
    {
         on reload
    }

    @Override
    public void onShutdown()
    {
         on shutdown
    }

    public class ZoneListener implements OnZoneEnterLeaveListener
    {
        @Override
        public void onZoneEnter(Zone zone, Creature cha)
        {
            ScheduledFuture<?> _checkTask = null;
            if (zone.getParams() == null || !cha.isPlayable()) 
                return;
            
            if (!cha.isPlayer()) 
                return;

            cha.getPlayer().sendMessage("You have entered in a PvP Zone!");
            cha.startPvPFlag(null);
            cha.getPlayer().sendMessage("You are now flagged!");

            _checkTask = ThreadPoolManager.getInstance().scheduleAtFixedRate(new checkZone((Player)cha, zone, _checkTask), 60000, 60000);
        }

        
        public class checkZone extends RunnableImpl
        {
            Player _cha;
            Zone _zone;
            ScheduledFuture<?> _checkTask;
            
            public checkZone(Player cha, Zone zone, ScheduledFuture<?> checkTask)
            {
                _cha = cha;
                _zone = zone;
                _checkTask = checkTask;
            }

            @Override
            public void runImpl() throws Exception
            {
                if(_cha.isInZone(_zone))
                {
                    _cha.startPvPFlag(null);
                }
                else
                {
                    _checkTask.cancel(true);
                    _checkTask = null;
                }
            }
            
        }
        
        @Override
        public void onZoneLeave(Zone zone, Creature cha)
        {
            if (cha == null) 
                return;
            cha.getPlayer().sendMessage("You have left the PvP Zone !");
            cha.getPlayer().stopPvPFlag();
        }

    }
}

---------------------------------------------------------------------------------------------------------------------------------------------------------

 

5 answers to this question

Recommended Posts

  • 0
Posted

Wrong section my friend.

 

As far as i can understand u want to make players flag whenever enter the zone. So ur first mistake starts here

  

27 minutes ago, ISAM_MISTRO said:

 

public class PvPZone implements ScriptFile

 

 

Wrong implementation

 

See other zones for reference, because this code is just wrong to begin with.

  • 0
Posted

Your problem is here:

 

if (_cha.isInZone(_zone)) {
  _cha.startPvPFlag(null);
} else {
  _checkTask.cancel(true);
  _checkTask = null;
}

 

Either the _cha is null which i doubt or the _checkTask future task is null.

Do a debug in those 2 variables.

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


  • Posts

    • L2Elixir – Patch 4 Is Live!   We’re working non-stop, day and night, to deliver the best possible quality and bring back what made L2Elixir special. This project is built with passion, not shortcuts — for the old-school players who remember, and the new ones who want to experience it properly. Thank you for being part of the journey. Together, we’re making L2Elixir great again ❤️ The legends never fade.    ⚙️ General Enabled Class Change service (same class type only) ALT + B → Services → Character Development Enabled Shift + Click on Treasure Chests Players can now identify real chests (Adena, scroll drops) and use Key / Unlock Event deaths now cancel only debuffs, All self buffs are preserved, fixes issues with Root and similar effects Bladedancer class can now log in even when Max Clients (2) is reached. Since an active Bladedancer is not available for every damage dealer and some players tried to abuse this via VPN or a second PC, this feature was added to keep things fair. protections applies, requires testing!    🎒 Items Crystallizing enchanted items now gives the correct increased crystal amount (retail-like behavior) Removed Agathion Seal Bracelet: Rudolph from Santa rewards (Gracia Final item) Added Dualsword Craft Stamp into Milestone Exchange list    🧙 Skills Fixed Banish Undead lethal chance Hot Springs Malaria and similar effects now level up faster while being attacked
    • thats new SEO level tricks you know nothing of noob - bottom line: exposed.
    • Warning: This guy is a big scammer, trying to sell everything, advertising for servers etc. That's his mail address evgesha.nrnr@gmail.com , stay away!   @Atom @Celestine
    • Warning: This guy is a big scammer, trying to sell everything, advertising for servers etc. That's his mail address evgesha.nrnr@gmail.com , stay away! @Celestine @Atom
  • 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