Jump to content

Recommended Posts

Posted

Hi there, i made this code today, because Sundays are kinda boring. It is one NPC again, which i like it a lot. It is not the NPC that i like, but its function.

So, with this NPC player is able to teleport with his party in an area where only parties allowed to teleport. Code is easy-configurable for new people in L2J developing. This code cointains, Allow-Checker that checks if player & his party allowed to enter in party area and have fun. NPC shows automatically in its dialog if player is allowed or not. However, it contains parties & players (inside party area) calculator, and sends it to HTML dialog automatically too. To enable this mod you have to do some modifications by your own because i am not able to guess which area you would like to make party area. If party allowed to enter, it removes from all party members the item consume & count, after that it teleports players.

 

How to enable parties & players calculator:

• Check "config"  variables in code, which are mentioned below.

• Choose which area you would like to make your party area & find its name (//zone_check with your GM character inside the zone).

• Find its folder-location. (Server/data/zones/(your zone location).xml

• Add in this zone an id (whatever you want) like that

• Add this id number on "config" variable in code (variable mentioned below)

 

Example:

I want make party area Abandoned Camp. I go with my GM character in Abandon Camp and i use //zone_check. It shows me nothing because this zone is nothing (Not effect zone, not water zone, etc...) because result from //zone_check was empty. So, i create a new folder on Server/data/zones/Test.xml and i install inside this code:

 

<zone name="Party Area" id="155" type="ArenaZone" (You can set here whatever you want) shape="NPoly" minZ="-15756" maxZ="11556">

<node X="-49881" Y="147747" />

<node X="-52646" Y="148679" />

<node X="-56224" Y="147232" />

<node X="-58319" Y="145146" />

<spawn X="83503" Y="149113" Z="-3405" />

</zone>

 

So, i have to add in my "config" variable this ID (155).

 

Ok, so lets continue to NPC, preview & code installation/modification.

 

Preview (HTM Dialog):

 

dialogv.png

 

conditionsl.png

 

Preview Dialog Messages:

 

•Leader

leadermsg.png

 

•Party Member

ptmesage.png

 

How to install:

 

1. Create a new java file on data/scripts/custom/PartyTeleporter/PartyTeleporter.java

 

Paste this code:

package custom.PartyTeleporter;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;

/**
* @author `Heroin
* Made For Maxcheaters.com
* PartyTeleporter
*/
public class PartyTeleporter extends Quest
{
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 = -56742; // npc id
private static final int locationY = 140569; // npc id
private static final int locationZ = -2625; // 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 = 155; //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/scripts/custom/PartyTeleporter/1.htm"; //html location.
private static String ItemName = ItemTable.getInstance().createDummyItem(ItemConsumeId).getItemName(); //Item name, Dont Change this


public PartyTeleporter(int questId, String name, String descr)
{
	super(questId, name, descr);
	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())
            if (zone.getId() == zoneId)
            {
                for (L2Character character : zone.getCharactersInside().values())
                    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())
            if (zone.getId() == zoneId)
            {
                for (L2Character character : zone.getCharactersInside().values())
                    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);//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, ppl, true);//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(player.getHtmlPrefix(), 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(-1, PartyTeleporter.class.getSimpleName(), "custom");
	System.out.println("Party Teleporter by `Heroin has been loaded successfully!");
}
}

 

2.Create a new htm file on data/scripts/custom/PartyTeleporter/1.htm

 

Paste this code ont it:

<html>
<title>%player%</title>
<body><center>
<img src="L2UI_CH3.herotower_deco" width=256 height=32></center><br>
You have to be a party leader in order to ask from me to teleport you and your party inside party area.<br>
Minimum Number Of Party Members: <font color="LEVEL">%minmembers%</font>.<br>
You are currently %allowed% to enter party area with your party.<br>
Party Teleport will cost you total: <font color="LEVEL">%price% %itemname%</font><br>
<center>
%parties%
%players%

<table><tr>
<td><button value="Teleport Me & My Party!" action="bypass -h Quest PartyTeleporter partytp" width=180 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr></table>


<br><br>
<center>
<img src="L2UI_CH3.herotower_deco" width=256 height=32></center>
</body></html>

 

3. Add script on scripts.cfg file:

custom/PartyTeleporter/PartyTeleporter.java

 

4. Run this query on your database or install the NPC by yourself.

INSERT INTO `npc` VALUES ('36650', '13173', 'PartyTeleporter', '1', 'MaxCheaters.com', '1', 'LineageNPC.clear_npc', '8.00', '19.00', '85', 'male', 'L2Npc', null, null, null, null, null, '40', '43', '30', '21', '20', '20', '0', '0', null, null, null, null, '230', '1', '0', '333', '0', '0', '0', '60.00000', '120.00000', '1', '1', '0', '0');

 

How to Modify:

 

Check Variables on code:

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 = -56742; // npc id
private static final int locationY = 140569; // npc id
private static final int locationZ = -2625; // 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 = 155; //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/scripts/custom/PartyTeleporter/1.htm"; //html location.

 

Credits & Idea: `Heroin

  • Upvote 1
Posted

First of all mine its totally different with totally different java and html code.

Secondly my code is consisted of only one script and one html.

 

p.s i am not even registered in l2jserver.com

 

Posted

First of all mine its totally different with totally different java and html code.

Secondly my code is consisted of only one script and one html.

 

p.s i am not even registered in l2jserver.com

 

main idea of yours? -party teleporter

main idea of FBIagent? -party teleporter

  • 3 weeks later...
Posted

help...

 

1. ERROR in \custom\PTTele\PTTele.java (at line 72)
        for (L2Character character : zone.getCharactersInside().values())
                                                                ^^^^^^
The method values() is undefined for the type Collection<L2Character>
----------
2. ERROR in \custom\PTTele\PTTele.java (at line 87)
        for (L2Character character : zone.getCharactersInside().values())
                                                                ^^^^^^
The method values() is undefined for the type Collection<L2Character>
----------
2 problems (2 errors)The method getAllZones() from the type com.l2jserver.gamese
rver.instancemanager.ZoneManager is deprecated
The method values() is undefined for the type java.util.Collection<com.l2jserver
.gameserver.model.actor.L2Character>
The method getAllZones() from the type com.l2jserver.gameserver.instancemanager.
ZoneManager is deprecated
The method values() is undefined for the type java.util.Collection<com.l2jserver
.gameserver.model.actor.L2Character>
Failed executing script: C:\L2J-Server\game\data\scripts\custom\PTTele
\PTTele.java. See PTTele.java.error.log for details.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • I'm using Myext64 HF and recently tried to replicate the "br_xmas09_event" Raising Rudolph Event. Detailed event information can be found at https://legacy-lineage2.com/news/_rudolf_the_red.html After configuring .eventdata.xml and starting the server, t  server log shows: 12/02/2025 15:39:01.809, [NO_ERROR] SpawnEx2 [br_xmas2009_invisible][schuttgart20_npc2213_xs03m1] [1][0][0][0][0][346796390] 12/02/2025 15:39:02.057, DummyPacket received from L2Server 12/02/2025 15:39:02.058, server socket close 312ac(f0820224) error(997) 12/02/2025 15:39:02.058, [CallStack][tid:0][tick:2][0] Begin 12/02/2025 15:39:02.058, [CallStack][tid:0][tick:2][1][0] void __cdecl IOThreadCallback::IOThread_common(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][2][1] void IOThread_common 1 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][3][2] void __cdecl CIOSocketEx<class CIOBufferEx<16384> >::Close(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][4][3] void __cdecl CServerSocket::OnClose(void) 12/02/2025 15:39:02.059, [CallStack][tid:0][tick:2][5] End l2server log: 12/02/2025 15:39:02.112, npc server closed(127.0.0.1) error: 64 read buffer size: (server:0 npc:0) 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.112, [NO_ERROR] L2Server is under protection mode!!! 12/02/2025 15:39:02.131, dwTime[0] < 80 !!!!!!! 12/02/2025 15:39:02.131, [CallStack][tid:7][tick:1][0] Begin 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][1][0] void __cdecl IOThreadCallback::IOThread_common(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][2][1] void IOThread_common 1 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][4][3] void __cdecl NpcSocket::OnClose(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][3][2] void __cdecl CIOSocketEx<class CIOBufferEx<16384> >::Close(void) 12/02/2025 15:39:02.132, [CallStack][tid:7][tick:1][5] End 12/02/2025 15:39:31.767, server closed(127.0.0.1) Error: 64 Read buffer size: (server:0 npc:0) 12/02/2025 15:39:31.768, [NO_ERROR] Logout All Characters : 1   The NPC server sent a packet to the L2 server while generating the br_xmas2009_invisible game NPC server, and the NPC server subsequently crashed.     After some digging, I found a clue in a very old MXC post, but the fix was for the GF version. The whole problem is in l2server side support for NPC function CreateOnePrivateNearUser. It sends CreatePacket but Koreans made some changes in it (added instance ID) so it got broken. As Santa event is the only AI that uses this function, they probably don't know about it    So is there a way to fix this problem, specifically for Myext64 HF? I'd be happy to buy him coffee.
    • Offtopic, personal attacks, probably too old to use that much memes and what's YOUR actual contribution to L2J, in order I laugh aswell ?   The main poster quotes my pack so I answer accordingly, while you advertise L2JFrozen in both of your posts - discontinued since 2014 (? 1132 rev), with none taking back the open source lead while anyone could.   If you're somewhat affiliated to hopzone, you probably packed way more money than me. Packs don't make any type of money (barely 100e/month) and if you would follow me, you would know there are ways to handle it or even getting paid.   Hope I was short enough, 🧂🤡.
    • Hi guys, this is a CMS im sharing for lineage 2 servers, im tired of the crap i see on new release servers. Dont let me start on the IA developed ones lmao.   📋 Description Free and open source template to create landing pages for Lineage 2 private servers. Designed with a dark fantasy theme and modern animations. ✨ Current Features This FREE version includes: Complete Landing Page - Professional design ready to use Multi-language Support - Spanish, English, Portuguese Dark Fantasy Theme - With animated UI elements Server Information - Rates, features, and rules Olympiad Ranking - Rankings display Download Section - For game client Skins and Animations Gallery Streaming Widget - Twitch/Kick integration Fully Customizable - Via configuration files ❌ Not Included in Free Version ❌ User Registration System ❌ Online Players Counter ❌ Donation Panel 💎 Premium Integrations IntegrationPrice Registration System $50 USD Online Players Counter $50 USD Donation Panel $50 USD   📧 Contact: https://gh0tstudio.com 🛠️ Tech Stack Technology    Version    Description React              19.2.0       UI Library TypeScript       5.8.2        Static typing Vite                 6.2.0         Build tool TailwindCSS   CDNCSS    Framework Lucide React   0.554.0         Icons i18next           23.16.0       Internationalization react-i18next   15.1.0        React bindings for i18n All documentation provided for AI AGENTS to make changes on the ui texts and so on. u can have a look on the cms fully working with donation panel, online count and register via: https://crmlineage2.vercel.app/ https://github.com/6h0T/CRM-LINEAGE2-FREE If u are in the lookings to develop a unique website for ur projects, u can dm me or contact me throw my socials on my profile. all code has encrypted references so any type of rebranding, copying or selling without authorization will result in take downs
    • Hello dude, i can help u out, i reached to u via DM, my studio is https://gh0tstudio.com i have worked with almost 40 brands on developing Private Lineage and Mu online servers, dashboard for vote pages and more. I sent u some examples too
    • L2 TARTARUS - HTML DESIGN       L2 KOMBAT - ANIMATED BORDER   L2 SERENITY - ANIMATED LOGO   L2 ARCANE - COMMUNITY BOARD     L2 AMERIKA - ADVERTISING BANNER   L2 ZERON - ADVERTISING BANNER  
  • 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