ton3 Posted July 13, 2015 Posted July 13, 2015 (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 July 13, 2015 by ton3
0 SweeTs Posted July 14, 2015 Posted July 14, 2015 (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 July 14, 2015 by SweeTs
0 ton3 Posted July 14, 2015 Author Posted July 14, 2015 using your code, see what happens when u enter flag_zone while u are flagged. Check the video please. http://youtu.be/ie5pGSj7g58
0 SweeTs Posted July 14, 2015 Posted July 14, 2015 I have some weird problems with YT, I can't watch any video o.O
0 ton3 Posted July 14, 2015 Author Posted July 14, 2015 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 SweeTs Posted July 14, 2015 Posted July 14, 2015 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 ton3 Posted July 14, 2015 Author Posted July 14, 2015 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 SweeTs Posted July 14, 2015 Posted July 14, 2015 What about updatePvPStatus() and updatePvPStatus(L2Character target)?
0 ton3 Posted July 14, 2015 Author Posted July 14, 2015 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 SweeTs Posted July 14, 2015 Posted July 14, 2015 Okay then, looks like the problem is inside PvpFlagTaskManager like Tk said. Let me see :P
0 SweeTs Posted July 14, 2015 Posted July 14, 2015 (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 July 14, 2015 by SweeTs
0 ton3 Posted July 14, 2015 Author Posted July 14, 2015 Thank you very much for ur patience, working as I wanted and I learned a thing or two from you.
Question
ton3
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 ton327 answers to this question
Recommended Posts