/**
* @author Mobius (based on Tenkai pvpzone)
*/
public class FindPvP implements IBypassHandler
{
private static final String[] COMMANDS =
{
"FindPvP"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!Config.ENABLE_FIND_PVP || !target.isNpc())
{
return false;
}
L2PcInstance mostPvP = null;
int max = -1;
for (L2PcInstance player : L2World.getInstance().getPlayers())
{
if ((player == null) //
|| (player.getPvpFlag() == 0) //
|| (player.getInstanceId() != 0) //
|| player.isGM() //
|| player.isInsideZone(ZoneId.PEACE) //
|| player.isInsideZone(ZoneId.SIEGE) //
|| player.isInsideZone(ZoneId.NO_SUMMON_FRIEND))
{
continue;
}
int count = 0;
for (L2PcInstance pl : L2World.getInstance().getVisibleObjects(player, L2PcInstance.class))
{
if ((pl.getPvpFlag() > 0) && !pl.isInsideZone(ZoneId.PEACE))
{
count++;
}
}
if (count > max)
{
max = count;
mostPvP = player;
}
}
if (mostPvP != null)
{
// Check if the player's clan is already outnumbering the PvP
if (activeChar.getClan() != null)
{
Map<Integer, Integer> clanNumbers = new HashMap<>();
int allyId = activeChar.getAllyId();
if (allyId == 0)
{
allyId = activeChar.getClanId();
}
clanNumbers.put(allyId, 1);
for (L2PcInstance known : L2World.getInstance().getVisibleObjects(mostPvP, L2PcInstance.class))
{
int knownAllyId = known.getAllyId();
if (knownAllyId == 0)
{
knownAllyId = known.getClanId();
}
if (knownAllyId != 0)
{
if (clanNumbers.containsKey(knownAllyId))
{
clanNumbers.put(knownAllyId, clanNumbers.get(knownAllyId) + 1);
}
else
{
clanNumbers.put(knownAllyId, 1);
}
}
}
int biggestAllyId = 0;
int biggestAmount = 2;
for (Entry<Integer, Integer> clanNumber : clanNumbers.entrySet())
{
if (clanNumber.getValue() > biggestAmount)
{
biggestAllyId = clanNumber.getKey();
biggestAmount = clanNumber.getValue();
}
}
if (biggestAllyId == allyId)
{
activeChar.sendPacket(new CreatureSay(0, ChatType.WHISPER, target.getName(), "Sorry, your clan/ally is outnumbering the place already so you can't move there."));
return true;
}
}
activeChar.teleToLocation((mostPvP.getX() + Rnd.get(300)) - 150, (mostPvP.getY() + Rnd.get(300)) - 150, mostPvP.getZ());
activeChar.setSpawnProtection(true);
if (!activeChar.isGM())
{
activeChar.setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_PVP_TIME);
activeChar.startPvPFlag();
}
}
else
{
activeChar.sendPacket(new CreatureSay(0, ChatType.WHISPER, target.getName(), "Sorry, I can't find anyone in flag status right now."));
}
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I am selling my l2jeternity high five (all inclusive option $300) license+daily $50(mission) mod, autofarm, this is a very good and stable H5 assembly on market if you know how to run it properly, project developer LordWinter also a very passionate person and active in daily basis, because I am no longer using it, selling this out to put in good use for new h5 l2project. I am selling this for $180, pm me for details/offer. thanks
*Sale and rebinding with the consent of the developer LordWinter
payment option : paypal/crypto
telegram:
@arcadin77
Hello friends, good morning, good afternoon or good evening, depending on the time you are seeing this! I have been trying to decompile and compile again with only the classes that I want LineageEffect.u for a few days now, but I have not been successful. Could someone help me by clearing up some doubts about how I can do this work and be successful?!
**INTERLUDE REMASTERED**
Moonland is a server that's been running for about three years without wipe, and they don't plan on wiping it anytime soon.
I'm selling my items or even the account due to not having much time to play anymore.
I'm selling only for $$$. Not going to disclose my nickname in the server, but here are some of the items:
Lvl 5 equipment for both mage and fighter
+100 mage pvp set
2mastery jewels for fighter, 2 for mage, blessed antharas, blessed queen ant, ring of fallen angel, earring of fafurion.
1k + col, VIP cosmetics for armor, agathion and weapons(duals + mage wep)
I'm only selling for real money via paypal or cs2 skins so don't offer me anything else.
Question
lazzytr
I use l2fandc files. I need a java code, I've been searching a lot and waiting for help.
What I want to do is to teleport to the players doing pvp. So it's like finding the flag player.
I found some files but they did not fit my system. I'm waiting for help..
EXAMPLE:
package handlers.bypasshandlers;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.handler.IBypassHandler;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
/**
* @author Mobius (based on Tenkai pvpzone)
*/
public class FindPvP implements IBypassHandler
{
private static final String[] COMMANDS =
{
"FindPvP"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!Config.ENABLE_FIND_PVP || !target.isNpc())
{
return false;
}
L2PcInstance mostPvP = null;
int max = -1;
for (L2PcInstance player : L2World.getInstance().getPlayers())
{
if ((player == null) //
|| (player.getPvpFlag() == 0) //
|| (player.getInstanceId() != 0) //
|| player.isGM() //
|| player.isInsideZone(ZoneId.PEACE) //
|| player.isInsideZone(ZoneId.SIEGE) //
|| player.isInsideZone(ZoneId.NO_SUMMON_FRIEND))
{
continue;
}
int count = 0;
for (L2PcInstance pl : L2World.getInstance().getVisibleObjects(player, L2PcInstance.class))
{
if ((pl.getPvpFlag() > 0) && !pl.isInsideZone(ZoneId.PEACE))
{
count++;
}
}
if (count > max)
{
max = count;
mostPvP = player;
}
}
if (mostPvP != null)
{
// Check if the player's clan is already outnumbering the PvP
if (activeChar.getClan() != null)
{
Map<Integer, Integer> clanNumbers = new HashMap<>();
int allyId = activeChar.getAllyId();
if (allyId == 0)
{
allyId = activeChar.getClanId();
}
clanNumbers.put(allyId, 1);
for (L2PcInstance known : L2World.getInstance().getVisibleObjects(mostPvP, L2PcInstance.class))
{
int knownAllyId = known.getAllyId();
if (knownAllyId == 0)
{
knownAllyId = known.getClanId();
}
if (knownAllyId != 0)
{
if (clanNumbers.containsKey(knownAllyId))
{
clanNumbers.put(knownAllyId, clanNumbers.get(knownAllyId) + 1);
}
else
{
clanNumbers.put(knownAllyId, 1);
}
}
}
int biggestAllyId = 0;
int biggestAmount = 2;
for (Entry<Integer, Integer> clanNumber : clanNumbers.entrySet())
{
if (clanNumber.getValue() > biggestAmount)
{
biggestAllyId = clanNumber.getKey();
biggestAmount = clanNumber.getValue();
}
}
if (biggestAllyId == allyId)
{
activeChar.sendPacket(new CreatureSay(0, ChatType.WHISPER, target.getName(), "Sorry, your clan/ally is outnumbering the place already so you can't move there."));
return true;
}
}
activeChar.teleToLocation((mostPvP.getX() + Rnd.get(300)) - 150, (mostPvP.getY() + Rnd.get(300)) - 150, mostPvP.getZ());
activeChar.setSpawnProtection(true);
if (!activeChar.isGM())
{
activeChar.setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_PVP_TIME);
activeChar.startPvPFlag();
}
}
else
{
activeChar.sendPacket(new CreatureSay(0, ChatType.WHISPER, target.getName(), "Sorry, I can't find anyone in flag status right now."));
}
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.