Jump to content
  • 0

Pvp Flag Time Inside Zone


Question

Posted (edited)

I have this code and still when my char kill another char inside zone the pvp flag is gone after 30sec.

public void updatePvPStatus()
	{
		if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.FLAG_ZONE)) 
			return;
		
		PvpFlagTaskManager.getInstance().add(this, Config.PVP_NORMAL_TIME);
		
		if (getPvpFlag() == 0)
			updatePvPFlag(1);
	}

and

public void updatePvPStatus(L2Character target)
	{
		final L2PcInstance player = target.getActingPlayer();
		if (player == null)
			return;
		
		if (isInDuel() && player.getDuelId() == getDuelId())
			return;
		
		if ((!isInsideZone(ZoneId.PVP) || !target.isInsideZone(ZoneId.PVP)) && player.getKarma() == 0)
		{
			PvpFlagTaskManager.getInstance().add(this, checkIfPvP(player) ? Config.PVP_PVP_TIME : Config.PVP_NORMAL_TIME);
			
			if (getPvpFlag() == 0)
				updatePvPFlag(1);
		}
	}

can someone point me what is wrong? thanks.

Edited by ton3

Recommended Posts

  • 0
Posted (edited)

Guess why.. While you walk inside the zone with flag, you break it all. Remove this

if (activeChar.getPvpFlag() == 0)

Use the code I gave you.

Edited by SweeTs
  • 0
Posted

well, the same thing is happening.

 

hit player outside zone> enter zone> flag is gone after 15sec and even if u hit flagged player inside zone ur pvp flag doesnt update.

  • 0
Posted

Are you sure you have registered the zone, is it working correctly? Do you see the msg onEnter to the zone? :D

 

I will check it on my own, then you can compare the code and check if you missed something.

  • 0
Posted

yes I registered zone and I can see onenter messages:

 

ZoneID.java

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.gameserver.model.zone;

/**
 * Zone Ids.
 * @author Zoey76
 */
public enum ZoneId
{
    PVP(0),
    PEACE(1),
    SIEGE(2),
    MOTHER_TREE(3),
    CLAN_HALL(4),
    NO_LANDING(5),
    WATER(6),
    JAIL(7),
    MONSTER_TRACK(8),
    CASTLE(9),
    SWAMP(10),
    NO_SUMMON_FRIEND(11),
    NO_STORE(12),
    TOWN(13),
    HQ(14),
    DANGER_AREA(15),
    CAST_ON_ARTIFACT(16),
    NO_RESTART(17),
    SCRIPT(18),
    FLAG_ZONE(19);
    
    private final int _id;
    
    private ZoneId(int id)
    {
        _id = id;
    }
    
    public int getId()
    {
        return _id;
    }
    
    public static int getZoneCount()
    {
        return values().length;
    }
}

L2FlagZone.java

/* This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package net.sf.l2j.gameserver.model.zone.type;

import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.zone.L2ZoneType;
import net.sf.l2j.gameserver.model.zone.ZoneId;
import net.sf.l2j.gameserver.network.SystemMessageId;

public class L2FlagZone extends L2ZoneType
{
       public L2FlagZone(final int id)
       {
               super(id);
       }

       @Override
       protected void onEnter(L2Character character)
       {
           if (character instanceof L2PcInstance)
           {
               L2PcInstance activeChar = ((L2PcInstance) character);
               
               activeChar.updatePvPFlag(1);
               activeChar.sendPacket(SystemMessageId.ENTERED_COMBAT_ZONE);
           }
           
           character.setInsideZone(ZoneId.FLAG_ZONE, true);
           character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, true);
       }

       @Override
       protected void onExit(final L2Character character)
       {
           if (character instanceof L2PcInstance)
           {
           L2PcInstance activeChar = ((L2PcInstance) character);
                   
                activeChar.updatePvPFlag(0);
                activeChar.sendPacket(SystemMessageId.LEFT_COMBAT_ZONE);
           }  
               
                character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false);
                character.setInsideZone(ZoneId.FLAG_ZONE, false);           
                  
               }
       

       @Override
       public void onDieInside(final L2Character character)
       {
           
       }
       @Override
       public void onReviveInside(final L2Character character)
       {
           
       }
}
  • 0
Posted
public void updatePvPStatus()
    {
        if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.FLAG_ZONE))
            return;
        
        PvpFlagTaskManager.getInstance().add(this, Config.PVP_NORMAL_TIME);
        
        if (getPvpFlag() == 0)
            updatePvPFlag(1);
    }

and

public void updatePvPStatus(L2Character target)
    {    
        final L2PcInstance player = target.getActingPlayer();
        if (player == null)
            return;
        
        if (isInDuel() && player.getDuelId() == getDuelId())
            return;
        
         if ((isInsideZone(ZoneId.FLAG_ZONE) && target.isInsideZone(ZoneId.FLAG_ZONE)))
         return;
                
         if ((!isInsideZone(ZoneId.PVP) || !target.isInsideZone(ZoneId.PVP)) && player.getKarma() == 0)
        {
            PvpFlagTaskManager.getInstance().add(this, checkIfPvP(player) ? Config.PVP_PVP_TIME : Config.PVP_NORMAL_TIME);
            
            if (getPvpFlag() == 0)
                updatePvPFlag(1);
        }
                
            
    }
  • 0
Posted (edited)

Add this check inside PvpFlagTaskManager

             final L2PcInstance player = entry.getKey();
             final long timeLeft = entry.getValue();
             
+            if (player.isInsideZone(ZoneId.FLAG_ZONE))
+                return;
+            
             // Time is running out, clear PvP flag and remove from list.
             if (currentTime > timeLeft)
             {
Edited by SweeTs
Guest
This topic is now closed to further replies.


×
×
  • 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