Jump to content
  • 0

Litle Help With Zone Checker


Question

Posted

I changed some things from this code http://www.maxcheaters.com/topic/156243-advanced-party-teleporter/ to make it working for acis, but the zone checker is not working at all, the number of players and parties inside still 0 even when someone is inside. Can someone help?

package net.sf.l2j.gameserver.scripting.scripts.custom;

import net.sf.l2j.gameserver.cache.HtmCache;
import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.instancemanager.ZoneManager;
import net.sf.l2j.gameserver.model.L2Party;
import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.zone.L2ZoneType;
import net.sf.l2j.gameserver.model.zone.type.L2FlagZone;
import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
import net.sf.l2j.gameserver.network.serverpackets.ItemList;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
import net.sf.l2j.gameserver.scripting.Quest;

/**
 * @author `Heroin
 * Made For Maxcheaters.com
 * PartyTeleporter
 */
public class PartyTeleporter extends Quest
{
    private static final String qn = "PartyTeleporter";
    
    private static final int npcid = 36650; // npc id
    //-------------------------------------
    //Teleport Location Coordinates X,Y,Z.
    //Use /loc command in game to find them.
    private static final int locationX = -10864; // npc id
    private static final int locationY = -185526; // npc id
    private static final int locationZ = -10946; // npc id
    //-------------------------------------
    //-------------------------------------
    // Select the id of your zone.
    // If you dont know how to find your zone id is simple.
    // Go to data/zones/(your zone file).xml and find your zone
    // E.g: <zone name="dion_monster_pvp" id="6" type="ArenaZone" shape="NPoly" minZ="-3596" maxZ="0">
    /**The id of your zone is id="6" */
    /**---------------------------------------------------------------------------*/
    /**WARNING: If your zone does not have any id or your location is not on any zone in data/zones/ folder, you have to add one by your self*/ // required to calculate parties & players
    /**---------------------------------------------------------------------------*/
    private static final int ZoneId = 19; //Here you have to set your zone Id
    //-------------------------------------
    private static final int MinPtMembers = 2; // Minimum Party Members Count For Enter on Zone.
    private static final int ItemConsumeId = 57; // Item Consume id.
    private static final int ItemConsumeNum = 100; // Item Consume Am.ount.
    private static final boolean ShowPlayersInside = true; //If you set it true, NPC will show how many players are inside area.
    private static final boolean ShowPartiesInside = true; //If you set it true, NPC will show how many parties are inside area.
    //-------------------------------------
    private static String htm = "data/html/partychecker/1.htm"; //html location.
    private static String ItemName = ItemTable.getInstance().createDummyItem(ItemConsumeId).getItemName(); //Item name, Dont Change this

    
    public PartyTeleporter()
    {
        super(-1, "custom");
        addFirstTalkId(npcid);
        addTalkId(npcid);
        addStartNpc(npcid);
    }
    
    @Override
    public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
    {
        if (event.startsWith("partytp"))
        {
            TP(event, npc, player, event);
        }

        return "";
    }
    @SuppressWarnings("deprecation")
    public int getPartiesInside(int zoneId)//Calculating parties inside party area.
    {
        int i = 0;
        for (L2ZoneType zone : ZoneManager.getInstance().getAllZones(L2FlagZone.class))
            if (zone.getId() == zoneId)
            {
                for (L2Character character : zone.getCharactersInside())
                    if (character instanceof L2PcInstance && (!((L2PcInstance) character).getClient().isDetached()) &&
                            ((L2PcInstance) character).getParty() != null &&
                            ((L2PcInstance) character).getParty().isLeader((L2PcInstance) character))
                        i++;
            }
        return i;
    }
    @SuppressWarnings("deprecation")
    public int getPlayerInside(int zoneId)//Calculating players inside party area.
    {
        int i = 0;
        for (L2ZoneType zone : ZoneManager.getInstance().getAllZones(L2FlagZone.class))
            if (zone.getId() == zoneId)
            {
                for (L2Character character : zone.getCharactersInside())
                    if (character instanceof L2PcInstance && (!((L2PcInstance) character).getClient().isDetached()))
                        i++;
            }
return i;
}
    private boolean PartyItemsOk(L2PcInstance player)
    //Checks if all party members have the item in their inventory.
    //If pt member has not enough items, party not allowed to enter.
    {
        
        try
        {
            for (L2PcInstance member : player.getParty().getPartyMembers())
            {
                if (member.getInventory().getItemByItemId(ItemConsumeId) == null)
                            
                {
                    player.sendMessage("Your party member "+member.getName()+" does not have enough items.");
                    return false;
                }
                if (member.getInventory().getItemByItemId(ItemConsumeId).getCount() < ItemConsumeNum)
                {
                    player.sendMessage("Your party member "+member.getName()+" does not have enough items.");
                    return false;
                }
            }
            return true;
            
        }
        catch (Exception e)
        {
            player.sendMessage("Something went wrong try again.");
            return true;
        }
    }

    private void proccessTP(L2PcInstance player) // Teleporting party members to zone
    {
        for (L2PcInstance member : player.getParty().getPartyMembers())
        {
            member.teleToLocation(locationX, locationY, locationZ, 0);//Location X, Y ,Z
        }
    }
    private void TP(String event, L2Npc npc, L2PcInstance player, String command) // Teleport player & his party
    {
        
        try
        {
            L2Party pt = player.getParty();
            if (pt == null)
            {
                player.sendMessage("You are not currently on party.");
                return;
            }
            if (!pt.isLeader(player))
            {
                player.sendMessage("You are not party leader.");
                return;
            }
            if (pt.getMemberCount() < MinPtMembers)
            {
                player.sendMessage("You are going to need a bigger party " +
                        "in order to enter party area.");
                return;
            }
            if (!PartyItemsOk(player))
            {
                return;
            }
            else
            {
                proccessTP(player);
                for (L2PcInstance ppl : pt.getPartyMembers())
                {
                    if (ppl.getObjectId() != player.getObjectId())//Dont send this message to pt leader.
                    {
                        ppl.sendMessage("Your party leader asked to teleport on party area!");//Message only to party members
                    }
                    ppl.sendMessage(ItemConsumeNum+" "+ItemName+" have been dissapeared.");//Item delete from inventory message
                    ppl.getInventory().destroyItemByItemId("Party_Teleporter", ItemConsumeId, ItemConsumeNum, player, null);//remove item from inventory
                    ppl.sendPacket(new InventoryUpdate());//Update
                    ppl.sendPacket(new ItemList(ppl, false));//Update
                    ppl.sendPacket(new StatusUpdate(ppl));//Update
                    
                }
                //Sends message to party leader.
                player.sendMessage(ItemConsumeNum*player.getParty().getMemberCount()+" "+ItemName+" dissapeard from your party.");
            }
            
        }
        catch (Exception e)
        {
            player.sendMessage("Something went wrong try again.");
        }
    }
    
    @Override
    public String onFirstTalk(L2Npc npc, L2PcInstance player)
    {
        final int npcId = npc.getNpcId();
        if (player.getQuestState(getName()) == null)
        {
            newQuestState(player);
        }
        if (npcId == npcid)
        {
            String html = HtmCache.getInstance().getHtm(htm);
            html = html.replaceAll("%player%", player.getName());//Replaces %player% with player name on html
            html = html.replaceAll("%itemname%", ItemName);//Item name replace on html
            html = html.replaceAll("%price%", player.getParty()!=null ? ""+ItemConsumeNum*player.getParty().getMemberCount()+"": "0");//Price calculate replace
            html = html.replaceAll("%minmembers%", ""+MinPtMembers);//Mimum entry party members replace
            html = html.replaceAll("%allowed%", isAllowedEnter(player) ? "<font color=00FF00>allowed</font>" :
                "<font color=FF0000>not allowed</font>");//Condition checker replace on html
            html = html.replaceAll("%parties%", ShowPartiesInside ? "<font color=FFA500>Parties Inside: "+getPartiesInside(ZoneId)+"</font><br>": "");//Parties inside
            html = html.replaceAll("%players%", ShowPlayersInside ? "<font color=FFA500>Players Inside: "+getPlayerInside(ZoneId)+"</font><br>": "");//Players Inside
            NpcHtmlMessage npcHtml = new NpcHtmlMessage(0);
            npcHtml.setHtml(html);
            player.sendPacket(npcHtml);
        }
        return "";
    }
    private boolean isAllowedEnter(L2PcInstance player) //Checks if player & his party is allowed to teleport.
    {
        if (player.getParty() != null)
        {
            if( player.getParty().getMemberCount() >= MinPtMembers && PartyItemsOk(player))//Party Length & Item Checker
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }
    public static void main(final String[] args)
    {
        new PartyTeleporter();
        System.out.println("Party Teleporter by `Heroin has been loaded successfully!");
    }
}

Recommended Posts

  • 0
Posted (edited)

SweeTs, I have this code and still not working, when partyleader goes outside zone he can teleport inside and all ur party will teleport again to the respawn.

   private boolean isAllowedEnter(L2PcInstance player) //Checks if player & his party is allowed to teleport.
    {
            
        if (player.getParty() != null)
        {
            for (final L2PcInstance member : player.getParty().getPartyMembers())
            {
                
            if (member.isInsideZone(ZoneId.FLAG_ZONE))    
                return false;
            
            else
            {
                return true;
            }
            }
            if( player.getParty().getMemberCount() >= MinPtMembers && PartyItemsOk(player))//Party Length & Item Checker
            {
                return true;
            }
            else
            {
                return false;
            }
            }
        
        
        return false;
    }
Edited by ton3
Guest
This topic is now closed to further replies.


  • Posts

    • Website: https://l2aurum.com/ Discord: https://discord.gg/ngaD9DJRjE   Dear Players, We are excited to announce that the x300 Summer Season Beta server will open on 19‑06‑2026 at 20:00 GMT+2. As previously mentioned, there will be no wipe and no account deletion. All accounts, characters, items, and progress from Season 1 will remain completely safe. To ensure a fair and competitive start for new players, all Season 1 accounts will be temporarily locked. The official Summer Season launch will take place on 26‑06‑2026 at 20:00 GMT+2. A few weeks after the official launch, Season 1 accounts will be unlocked so previous players can access their characters and continue their journey. This approach allows new players to enjoy a fresh start while preserving the progress and achievements of our long-term community. Thank you for your continued support, and we look forward to welcoming everyone to the new Summer Season. L2Aurum Team   Explore L2 Aurum Features Discover the Enhancements that set us apart!   Information Server Version: Interlude - PvP Server Client Interface: Unique Interface   Rates     Additional Features and changes When you create a new character, you will start in Giran Harbor at Level 1, equipped with full No-Grade items. Auto Farm is available for free for 2 hour daily without VIP. VIP players receive 4 hours of Auto Farm per day. The Auto Farm time resets with the server restart at 5:30 AM. Status Noblesse: Last hit Barakiel. Player Spawn Protection: 7 seconds. Geodata + Pathnodes: Enabled. All commands are available in the Community Board. Maximum 3 Bishops Per Party: Enabled. Boss Protect - Anti-Zerg: Enabled. Shift + click on monsters to see the droplist. Offline shop. Mana Potion Restores 1000 MP with a cooldown of 8 seconds. Inventory Slots: 250.   Weapon Information Lv1 Black Chaotic Weapons. Lv2 Aurum Weapons.   Armor Information Lv1 Blue Apella Armor. Lv2 Aurum Apella Armor. Misc additions Accessories +50 and +150 pdef|mdef. Tattoos: Resolve | Soul | Avadon. Agathions: Cosmetic only (no stats).   Buffs / Dances / Songs / Prophecies Duration: 2 hours. Total Buff Slots: 32 + 4 (Divine Inspiration). Vote Buff: You must vote on 3 of 6 vote sites to get the vote buff blessing. Castle Reward Every clan that captures a castle receives the castle owner clan blessing buff. To receive it, the clan leader must be online.   Events   Raid Bosses Epic Bosses Final Bosses     For full server information please visit website PvP: Server Features   Website: https://l2aurum.com/ Discord: https://discord.gg/ngaD9DJRjE      
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..