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

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

    • Estou procurando cloacks do classic adaptadas para cliente interlude.
    • Good luck with your sales, but: Demo video. Show the siege, the olympiad, the tvt when you are selling something so complex and expensive.
    • 1.8 BILION NEW STOCK.70 E PER BILION DISCOUNT IF BUY ALL
    • ============================================================== VIKOS AUTOBOTS — live bots for Lineage 2 servers on Lucera2 Interlude and Classic ============================================================== An empty server loses players. Vikos Autobots fills the world with bots that act like real players: they farm, walk around towns, join clans, fight wars, go to raids, sieges, events and the Olympiad, trade and talk in chat. Installs on top of a Lucera2 build: one .ext.jar + the data/autobots folder + a config. Database tables are created automatically. WHAT THE BOTS DO • Farm zones by level along set routes; they do not steal mobs from players or other bots. Leave town through gatekeepers (custom ones and NPC bypasses too) and come back. • Some bots leave the farm to walk around town while others keep farming, so towns are not empty. They walk, talk to NPCs and sit down to rest (can be turned off for PvP servers). • After a server restart bots carry on where they were: same zone, same route, no mass teleport to town. • Class-based combat AI: fighters, archers, mages, healers, buffers, summoners. Auto parties, healers resurrect the dead. • Real fishing with core skills (cast, Pumping / Reeling, fish fight). Rod by grade, bait and fishing shots are handed out automatically; spots have stands, a bot limit, levels and time. • Gear by class and level, a separate Olympiad set and an "online time" set; custom skills by class and by online time (same idea as time gear). Random enchant, Life Stones, dyes, buffs. Shots, potions, arrows and scrolls restock on their own; bot items never reach the economy. • Clans and alliances with generated crests, clan wars, clan defense, PvP server mode. PvP zones (arena, Coliseum, custom): admin Send or a clock like TvT (14:00;16:00). • Raids and epics (Antharas, Valakas, Baium; more via XML), with a gathering in town or a direct teleport to the boss. Castle sieges, TvT / CTF / DM, Olympiad 1v1 and 3v3, Seven Signs. • Private stores (sell and buy), RU/EN chat, AI chat (Groq or any OpenAI-compatible API), bot replies go through your server chat filter (chatfilters.xml), player PMs forwarded to admin Telegram. • Admin panel: //autobots panel. Online schedule, own AI thread pool built for hundreds of bots online, one commented config and XML files checked at server start. INCLUDED: VIKOS AUTOBOTS CONFIGURATOR (Windows) • A single .exe with Java inside, nothing to install. • Works right on your VPS over SSH/SFTP: edit and save, the files go straight to the server; the old version goes to backup. • World map from server geodata, automatic route building by the core movement rules with checks. • Farm zones, towns, raids, sieges, TvT, PvP zones, fishing spots. • Editors with client icons: equipment (farm / online time / Olympiad), skills (regular and by online time), buffs, Life Stones, supplies, dyes. Finds config mistakes by itself. • Interlude and Classic, RU/EN interface, light and dark theme, F1 help. ============================================================== VIKOS AUTOBOTS — REAL SERVER LOAD Measured ============================================================== Interlude test server on Lucera2, a regular VPS: • 4 vCPU, 8 GB RAM, Debian 13 • Java 17 (Temurin), -Xmx5G • MariaDB -------------------------------------------------------------- RESULTS -------------------------------------------------------------- CPU is a one-minute average for the whole game server process: core, mobs and bots together. 400% = all 4 cores. Bots online Server CPU (of 400%) Share of VPS 1000 ~103% ~26% 1200 ~105% ~26% 1500 ~120-150% ~30-37% • An empty server without bots uses ~40% by itself, so 1000 bots add about one core. • The bot AI itself (all bots together) takes 10-15% of one core for 1000-1500 bots. • Memory is stable, no leaks: - after GC the heap stays at ~2.8-2.9 GB with 800, 1000 and 1200 bots — about the same as the server uses by itself, without bots; - the heap low point does not grow over time: memory does not pile up, it is freed on every garbage collection; - a full night with 1500 bots with no out-of-memory errors (OutOfMemory), the server never crashed; - with -Xmx5G there is more than 2 GB of headroom. • A full night with 1500 bots ran stable. Meanwhile the bots live a full life: farming along routes, walking around towns, fishing, clans, scheduled PvP zones, TvT/CTF, Olympiad and raids. -------------------------------------------------------------- SETTINGS USED FOR THESE NUMBERS -------------------------------------------------------------- • AutobotsIterationDelayMs = 500 A bot thinks twice per second: enough to act like a real player without wasting CPU. • AutobotsMaxBots = 1000-1500 • ai.properties: AiTaskActiveDelay = 500 AggroCheckInterval = 500 Most of the load comes not from the bot code but from the mobs around the bots: bots bring locations to life, and the mobs start checking whom to attack. With these values they check twice per second instead of four times. The load is almost halved, and you can't see the difference: a mob notices its target a fraction of a second later. • MariaDB: innodb_flush_log_at_trx_commit = 2 The database flushes its log to disk once per second instead of after every small query. With 1000+ bots there are many queries, and this removes most of the database load. A standard setting for game servers. • server.properties: AutoDestroyDroppedItemAfter = 120 Drops on the ground disappear after 2 minutes instead of 10. Bots kill a lot, and in 10 minutes tens of thousands of items piled up on the ground: extra memory, extra server work and database deletes. Two minutes is enough for players to pick up their own drops. Rule of thumb: a 4-core VPS handles 1000-1500 bots comfortably. For more, go for 6-8 cores. LICENSE • The license is bound to your VPS IP: the bots run only on the server with that IP. • Send the server IP when you buy. Price: 500$ Contact: Telegram @Vikos177 — https://t.me/Vikos177 Test the bots here: <DOWNLOAD LINK> https://drive.google.com/file/d/1xpOII2X2fsUWekDIJk7POTMWu7ICpHJo/view After purchase you are added to a private Telegram group for clients: news, updates and support. ==============================================================
    • 💻 Supercharge your workflow with Claude Pro & Cursor AI. Clean setups with full warranty included!
  • 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..