Jump to content
  • 0

Advanced Party Teleporter


Tachi

Question

main code :  http://www.maxcheaters.com/topic/156243-advanced-party-teleporter/


 


 


i have a problem with this code  :)


 


can you give me any ideea ?


 


http://imgur.com/qSERSlm

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

 

main code :  http://www.maxcheaters.com/topic/156243-advanced-party-teleporter/

 

 

i have a problem with this code  :)

 

can you give me any ideea ?

 

http://imgur.com/qSERSlm

 

just create your own..you have one l2TeleporterInstance Use It And Change Method doTeleport with what you want...

Link to comment
Share on other sites

  • 0

just create your own..you have one l2TeleporterInstance Use It And Change Method doTeleport with what you want...

i fixeed 1 problem but i have the last :(

 

http://imgur.com/uXwqMFA

Link to comment
Share on other sites

  • 0
package custom.PartyTeleporter;
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.quest.Quest;
import net.sf.l2j.gameserver.model.zone.L2ZoneType;
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;

/**
 * @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(L2PcInstance.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!");
	}
}

here you have all code

Link to comment
Share on other sites

  • 0

 

package custom.PartyTeleporter;
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.quest.Quest;
import net.sf.l2j.gameserver.model.zone.L2ZoneType;
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;

/**
 * @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(L2PcInstance.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!");
	}
}
here you have all code

When i go home i will give a try but like i said use your own l2PartyTeleporter with L2TeleporterInstance And Create Your Teleports In method doteleport...

Link to comment
Share on other sites

  • 0

Replace values() with size().

 

Also, the code is soo crappy. Your check is also so poor. Your getPlayersInside which uses 13 lines, can be reduced to.. 0. Yes, 0. Delete that godamn method and use

 

 

ZoneManager.getInstance().getZoneById(999).getKnownTypeInside(L2PcInstance.class).size()
Edited by SweeTs
Link to comment
Share on other sites

  • 0

 

Replace values() with size().

 

Also, the code is soo crappy. Your check is also so poor. Your getPlayersInside which uses 13 lines, can be reduced to.. 0. Yes, 0. Delete that godamn method and use

ZoneManager.getInstance().getZoneById(999).getKnownTypeInside(L2PcInstance.class).size()

 

The joy to use aCis. And it's 1, not 0. Scammer !

Edited by Tryskell
Link to comment
Share on other sites

  • 0

The joy to use aCis. And it's 1, not 0. Scammer !

0, since the whole method disappears and my line replace the line in showChatWindow :D

 

QQ :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.



×
×
  • Create New...