Jump to content
  • 0

Go to pvp players


lazzytr

Question

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;
    }
}

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • DISCORD : utchiha_market telegram  https://t.me/utchiha_market SELLIX STORE : https://utchiha-market.mysellix.io/ Join the server for more products : https://discord.gg/hoodservices
    • 🌟 Welcome to the dawn of a new adventure in the realm of Lineage 2 Supreme! 🌟 Prepare yourself for an epic journey that transcends time and space. Our upcoming project promises to deliver the ultimate mid-rate experience, where heroes are forged and legends are born. Stay tuned for updates as we embark on this thrilling journey together. The realm of Lineage 2 awaits, and destiny beckons. Are you ready to answer the call? www.l2supreme.cc https://discord.com/invite/QA32rQ77nM
    • Official Website @>> https://www.eventbrite.com/e/biopeak-male-enhancement-reviews-warning-important-information-no-one-will-tell-you-tickets-894184589177   Biopeak Male Enhancement:- Considering the mind-boggling interest in their products, the organization needed to confine the quantity of units ready to move. We considered what compelled this sugary treat to surprise the world, and we discussed whether it satisfied our grand assumptions,    https://www.facebook.com/BiopeakMaleEnhancementInUS/ https://www.facebook.com/Get.BiopeakMaleEnhancementUS/   https://trybiopeakme.clubeo.com/calendar/2024/04/29/biopeak-male-enhancement-reviews-the-disturbing-biopeak-supplements-truth https://trybiopeakme.clubeo.com/calendar/2024/04/28/biopeak-male-enhancement-reviews-warning-important-information-no-one-will-tell-you https://trybiopeakme.clubeo.com/calendar/2024/04/28/biopeak-male-enhancement-reviews-truth-exposed-2024-biopeak-supplements-usa-for-men https://medium.com/@BiopeakMaleEnhancementBuyNow/biopeak-male-enhancement-reviews-revitalize-your-sexual-biopeak-supplements-health-with-1b0dcc117608 https://medium.com/@BiopeakMaleEnhancementBuyNow/biopeak-male-enhancement-reviews-warning-usa-ca-important-information-no-one-will-tell-you-f375f53b3cd9 https://medium.com/@BiopeakMaleEnhancementBuyNow/biopeak-male-enhancement-reviews-truth-exposed-2024-is-biopeak-supplements-it-scam-or-real-9b8fc49be4c3 https://medium.com/@BiopeakMaleEnhancementBuyNow/be-informed-biopeak-male-enhancement-reviews-on-scam-alert-this-enhancement-for-male-female-2d49c8f9ec17   Nexalyn Norway Official Links   https://www.facebook.com/NexalynInNorway/ https://www.facebook.com/NexalynNorway/ https://nexalyn-norway.company.site/ https://nexalyn-norway.jimdosite.com/ https://nexalyn-norway-1.jimdosite.com/   https://infogram.com/nexalyn-norway-reviews-advarsel-viktig-informasjon-ingen-vil-fortelle-deg-1h0n25oyjvynz4p?live https://medium.com/@NexalynNorway/nexalyn-norway-reviews-truth-exposed-2024-nexalyn-tablet-iceland-for-men-ad3f06ce6c83 https://medium.com/@NexalynNorway/nexalyn-norway-reviews-2024-er-nexalyn-tablet-iceland-lovlig-eller-svindel-ac2a9a8506d3 https://medium.com/@NexalynNorway/nexalyn-norway-reviews-revitalisere-din-nexalyn-tablet-seksuelle-helse-med-a0d44852760c https://bonniedgrafh.clubeo.com/calendar/2024/04/26/nexalyn-norway-reviews-does-it-really-work https://bonniedgrafh.clubeo.com/calendar/2024/04/26/nexalyn-norway-reviews-revitalisere-din-nexalyn-tablet-seksuelle-helse-med https://bonniedgrafh.clubeo.com/calendar/2024/04/27/nexalyn-norway-reviews-advarsel-viktig-informasjon-ingen-vil-fortelle-deg https://bonniedgrafh.clubeo.com/calendar/2024/04/26/nexalyn-norway-reviews-testo-booster-pills-real-buyers-alert https://medium.com/@NexalynNorway/v%C3%A6r-informert-nexalyn-norway-reviews-om-svindelvarsel-denne-forbedringen-for-mannlig-og-kvinnelig-f52047570116
    • WELCOME TO THE BOXID MARKETPLACE THE BOXID is the best place to buy accounts in bulk. Also on THE BOXID there are any services for digital marketing and arbitrage! We offer cheap accounts and provide flexible prices, discounts and bonuses for loyal customers. If you want to make a bulk order, specify the quantity of items in the checkout form or contact our manager and ask for help with your bulk purchase. We sell social media at the most affordable price! https://theboxid.com/category/accounts/
    • Hello, I am adapting it to acis 401, and when I run it in the game it tells me: No rights defined for admin command 'admin_search'. Admin tried to use admin command 'admin_search', but has no access to use it.   Also try to adapt it in AdminAdmin.java with else in the last lines using it as admin_buscar (buscar = search in spanish) and I get the same error: No rights defined for admin command 'admin_buscar'. Admin tried to use admin command 'admin_search', but has no access to use it. I have the AdminSearch.java like this: package net.sf.l2j.gameserver.handler.admincommandhandlers; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; import net.sf.l2j.commons.lang.StringUtil; import net.sf.l2j.commons.math.MathUtil; import net.sf.l2j.gameserver.data.xml.ItemData; import net.sf.l2j.gameserver.handler.IAdminCommandHandler; import net.sf.l2j.gameserver.model.WorldObject; import net.sf.l2j.gameserver.model.actor.Player; import net.sf.l2j.gameserver.model.item.kind.Item; import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage; public class AdminSearch implements IAdminCommandHandler { private static final String[] ADMIN_COMMANDS = { "admin_search" }; private static final int PAGE_LIMIT = 15; @Override public void useAdminCommand(String command, Player activeChar) { if (command.startsWith("admin_search")) { StringTokenizer st = new StringTokenizer(command, " "); st.nextToken(); if (!st.hasMoreTokens()) { final NpcHtmlMessage html = new NpcHtmlMessage(0); html.setFile("data/html/admin/search.htm"); html.replace("%items%", ""); html.replace("%pages%", ""); activeChar.sendPacket(html); } else { final String item = st.nextToken(); int page = 1; if (st.hasMoreTokens()) { try { page = Integer.parseInt(st.nextToken()); } catch (NumberFormatException e) { page = 1; } } results(activeChar, item, page); } } return; } private static void results(Player activeChar, String item, int page) { final NpcHtmlMessage html = new NpcHtmlMessage(0); html.setFile("data/html/admin/search.htm"); //List<Item> items = new ArrayList<>();//no sirvio List<Object> items = Arrays.asList(ItemData.getInstance().getAllItems()); for (Object itemName : items) if (itemName != null) if (((WorldObject) itemName).getName().toLowerCase().contains(item.toLowerCase())) items.add(itemName); if (items.isEmpty()) { html.replace("%items%", "<tr><td>No items found with word " + item + ".</td></tr>"); html.replace("%pages%", ""); activeChar.sendPacket(html); return; } final int max = Math.min(100, MathUtil.countPagesNumber(items.size(), PAGE_LIMIT)); items = items.subList((page - 1) * PAGE_LIMIT, Math.min(page * PAGE_LIMIT, items.size())); final StringBuilder sb = new StringBuilder(); for (Object itemName : items) { String actualName = getFontedWord(item, ((WorldObject) itemName).getName()); StringUtil.append(sb, "<tr><td>", actualName, " (", ((Item) itemName).getItemId(), ")", "</td></tr>"); } html.replace("%items%", sb.toString()); sb.setLength(0); for (int i = 0; i < max; i++) { final int pagenr = i + 1; if (page == pagenr) StringUtil.append(sb, pagenr, "&nbsp;"); else StringUtil.append(sb, "<a action=\"bypass -h admin_search ", item, " ", pagenr, "\">", pagenr, "</a>&nbsp;"); } html.replace("%pages%", sb.toString()); activeChar.sendPacket(html); } private static String getFontedWord(String word, String tt) { int position = tt.toLowerCase().indexOf(word.toLowerCase()); StringBuilder str = new StringBuilder(tt); String font = "<FONT COLOR=\"LEVEL\">"; str.insert(position, font); str.insert(position + (font.length() + word.length()), "</FONT>"); return str.toString(); } @Override public String[] getAdminCommandList() { return ADMIN_COMMANDS; } } Can someone give me a hand and tell me what I'm doing wrong?  
  • Topics

×
×
  • Create New...