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)

u mean this or the .xml?

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

My zone is the last.

Edited by ton3
  • 0
Posted

fixed by adding id to .xml file,  SweeTs just another question.

 

-When you are the partyleader and use SoE from the zone all the members from your party will stay inside. (no problem here)

-If you are partyleader and talk to gk again you will teleport your party again to the respawn even if the party members are already inside ( this is my problem)

 

 

How hard is to add a check to not let the partyleader teleport again inside if his party is already inside? I hope i was clear enough

  • 0
Posted

 

rivate static final int ZoneId = 19; //Here you have to set your zone Id

 

It's not working, but the coutner checks for the zone id..

 

if (zone.getId() == zoneId)
{
...
  • 0
Posted

fixed by adding id to .xml file,  SweeTs just another question.

 

-When you are the partyleader and use SoE from the zone all the members from your party will stay inside. (no problem here)

-If you are partyleader and talk to gk again you will teleport your party again to the respawn even if the party members are already inside ( this is my problem)

 

 

How hard is to add a check to not let the partyleader teleport again inside if his party is already inside? I hope i was clear enough

 

is there any file I could look to add this check?

  • 0
Posted

Add one more check inside isAllowedEnter(), you have to check for party members (for loop) if they are inside your zone or not, if yes return false, else true.

  • 0
Posted (edited)


for (L2PcInstance party: player.getParty().getPartyMembers())

{

     party.blabla(); <--- check if the party is inside your zone here

 

Edited by SweeTs
  • 0
Posted (edited)

http://joxi.ru/v29dLdqfxZPjmG

 

 private static final int ZoneId = 19; //Here you have to set your zone Id

The method isInsideZone(ZoneId) in the type L2Character is not applicable for the arguments (int)

what this error means?

Edited by ton3
  • 0
Posted (edited)

Most likely you did not import ZoneId and even worse, you have a stupid int there (private static final int ZoneId = 19) and probably it's reading this as ZoneId..

 

Do not rendomly copy/paste.. Peace was an example.. Write there your custom zone = FLAG_ZONE

 

and you are supposed to make an IF check...

if (party.isInsideZone(ZoneId.PEACE))
    return false;

Errrrrm

Edited by SweeTs
Guest
This topic is now closed to further replies.


  • Posts

    • Hey everyone, I’m thrilled to introduce our upcoming server, Dragon‑Network, built on the powerful Interlude+ chronicle and crafted for serious PvP, balanced progression and community fun. Below you’ll find all the key details — rates, features, event structure, and why this will be your next home for Lineage 2. 📅 Grand Opening November 21, 2025 — mark the date, rally your friends, prepare your gear. The realm opens, and the wars begin. ⚙️ Rates & Server Setup XP: 10× Chronicle: Interlude+ (expanded from our previous server) PvP-focused content, daily events, and reward-rich systems These core settings ensure you’ll feel progress and power, without losing the depth of classic Interlude. 🎯 Features & Highlights Based on our features page: Alternative class change quests: skip the lengthy standard quests by collecting tradable items dropped by monsters. Dragon-Network Full Interlude+ content: Kamaloka, Labyrinth, Pailaka quests, Hellbound Island, S80 items, Attribute system, Isle of Prayer hunting zone, siegeable fortresses and more. Dragon-Network Daily Team vs Team (TvT) events: prove your worth, climb the ranks and earn valuable rewards. Dragon-Network Balanced PvP mechanics: custom sub-stack features, armor mastery rules, optimized skill effects — all to keep the fight fair and skill-based. Dragon-Network Other extras: Raid Bosses with defined respawn times, rich loot systems, improved QOL features like improved buffs, combo songs/dances, tattoo system, etc. Dragon-Network 🎮 Why This Server Matters You’re playing Interlude+, but with modern enhancements — classic content with new mechanics, not a simple resurrect of the old. PvP and events are daily and structured, so you don’t wait weeks to engage. We’ve designed progression to be meaningful: rewards, class changes, content unlocks all move you forward without feeling pay-to-win. Community-first: Whether you enter solo or with friends, you’ll find team action, clans forming, and events where everyone has a chance to shine. 🗺 What to Do Next Visit our website: dragon-network.eu (check out the “Features” tab for full details) Prepare your Master Account, get your clan or buddies ready. On launch day (Nov 21), log in early, grab your spot, participate in the first TvT, and start building your legacy. Get ready — the gates open soon. The grind begins. The battles await. Will you rise to become legend on Dragon-Network? 🐉 Feel free to ask any questions below or share this post with your friends. Let’s make this launch one to remember.
    • NFT gifts on Telegram are already here! Buy Stars at SOCNET — the black background can be yours today! Purchase existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium, and react to messages in channels! Low prices, many payment methods, and other cool and unique features! Try it today — SOCNET STARS BOT Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and beneficial purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing our products and services: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in September! You can also use the first-purchase promo code: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply write your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." — you need to post it in our forum thread! 3. Get $1 for your first SMM Panel trial: just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts & Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • NFT gifts on Telegram are already here! Buy Stars at SOCNET — the black background can be yours today! Purchase existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium, and react to messages in channels! Low prices, many payment methods, and other cool and unique features! Try it today — SOCNET STARS BOT Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and beneficial purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing our products and services: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in September! You can also use the first-purchase promo code: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply write your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." — you need to post it in our forum thread! 3. Get $1 for your first SMM Panel trial: just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts & Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • NFT gifts on Telegram are already here! Buy Stars at SOCNET — the black background can be yours today! Purchase existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium, and react to messages in channels! Low prices, many payment methods, and other cool and unique features! Try it today — SOCNET STARS BOT Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and beneficial purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing our products and services: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in September! You can also use the first-purchase promo code: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply write your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." — you need to post it in our forum thread! 3. Get $1 for your first SMM Panel trial: just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! News: ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ WhatsApp Channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord Server: https://discord.gg/y9AStFFsrh Contacts & Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Wts adena 1kk = 10$  discord - GODDARDSHOP 
  • Topics

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