saulea90 0 Опубликовано 27 февраля, 2016 (изменено) Good evening, I have a problem with the party teleport,We finished adding Java code successfully without failure. but when I talk to npc not display any one html this my code config/custom.properties config/custom.properties #============================================================= # Npc Party Teleporter #============================================================= # Enable the Character Killing Monuments # NPC Id NpcPtTeleporterId= 36613 # Teleport coordinates PtTeleportX = -56781 PtTeleportY = 140545 PtTeleportZ = -2629 # ZoneId NpcPtZoneID default: 911 # 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"> NpcPtZoneID = 255 # Min party members NpcPtMinPartyMembers = 2 # Consume Item Id NpcPtConsumeItemId = 57 # Consume Item Quantity NpcPtConsumeItemQt = 100 # Show Inside players in zone NpcPtShowInsidePlayers = True # Show Inside Parties in zone NpcPtShowInsideParties = True java/net/sf/l2j/Config.java @@ -0,0 +1,1513 @@ + public static final String CUSTOM_FILE = "./config/custom.properties"; + + // -------------------------------------------------- + // Custom settings + // -------------------------------------------------- + public static int NPC_ID_PT_TELEPORTER; + public static int NPC_PT_TELEPORTER_X; + public static int NPC_PT_TELEPORTER_Y; + public static int NPC_PT_TELEPORTER_Z; + public static int NPC_PT_ZONEID; + public static int NPC_PT_MINPT_MEMBERS; + public static int NPC_PT_ITEMCONSUME_ID; + public static int NPC_PT_ITEMCOMSUME_QT; + public static boolean NPC_PT_SHOWINSIDE_PLAYERS; + public static boolean NPC_PT_SHOWINSIDE_PARTIES; + FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector"); FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector"); _log.info("Loading gameserver configuration files."); + // Custom settings + ExProperties custom = load(CUSTOM_FILE); + NPC_ID_PT_TELEPORTER = custom.getProperty("NpcPtTeleporterId", 36614); + NPC_PT_TELEPORTER_X = custom.getProperty("PtTeleportX", -56742); + NPC_PT_TELEPORTER_Y = custom.getProperty("PtTeleportY", 140569); + NPC_PT_TELEPORTER_Z = custom.getProperty("PtTeleportZ", -2625); + NPC_PT_ZONEID = custom.getProperty("NpcPtZoneID", 155); + NPC_PT_MINPT_MEMBERS = custom.getProperty("NpcPtMinPartyMembers", 2); + NPC_PT_ITEMCONSUME_ID = custom.getProperty("NpcPtConsumeItemId", 57); + NPC_PT_ITEMCOMSUME_QT = custom.getProperty("NpcPtConsumeItemQt", 100); + NPC_PT_SHOWINSIDE_PLAYERS = custom.getProperty("NpcPtShowInsidePlayers", true); + NPC_PT_SHOWINSIDE_PARTIES = custom.getProperty("NpcPtShowInsideParties", true); + // Clans settings ExProperties clans = load(CLANS_FILE); java/net/sf/l2j/gameserver/model/actor/instance/L2PartyTeleporterInstance.java @@ -0,0 +1,234 @@ +package net.sf.l2j.gameserver.model.actor.instance; + +import java.util.StringTokenizer; + +import net.sf.l2j.Config; +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.template.NpcTemplate; +import net.sf.l2j.gameserver.model.zone.L2ZoneType; +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed; +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 Adapter Gandalf PartyTeleporter, Lucas Fernandes + */ +public class L2PartyTeleporterInstance extends L2NpcInstance +{ + private static final int npcid = Config.NPC_ID_PT_TELEPORTER; // npc id + // ------------------------------------- + // Teleport Location Coordinates X,Y,Z. + // Use /loc command in game to find them. + private static final int locationX = Config.NPC_PT_TELEPORTER_X; // npc id + private static final int locationY = Config.NPC_PT_TELEPORTER_Y; // npc id + private static final int locationZ = Config.NPC_PT_TELEPORTER_Z; // 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 = Config.NPC_PT_ZONEID; // Here you have to set your zone Id + // ------------------------------------- + private static final int MinPtMembers = Config.NPC_PT_MINPT_MEMBERS; // Minimum Party Members Count For Enter on Zone. + private static final int ItemConsumeId = Config.NPC_PT_ITEMCONSUME_ID; // Item Consume id. + private static final int ItemConsumeNum = Config.NPC_PT_ITEMCOMSUME_QT; // Item Consume Am.ount. + private static final boolean ShowPlayersInside = Config.NPC_PT_SHOWINSIDE_PLAYERS; // If you set it true, NPC will show how many players are inside area. + private static final boolean ShowPartiesInside = Config.NPC_PT_SHOWINSIDE_PARTIES; // If you set it true, NPC will show how many parties are inside area. + private static String ItemName = ItemTable.getInstance().getTemplate(ItemConsumeId).getName(); // Item name, Dont Change this + private String htmContent; + + public L2PartyTeleporterInstance(int objectId, NpcTemplate template) + { + super(objectId, template); + } + + @Override + public void onBypassFeedback(L2PcInstance player, String command) + { + player.sendPacket(ActionFailed.STATIC_PACKET); + + StringTokenizer st = new StringTokenizer(command, " "); + String actualCommand = st.nextToken(); // Get actual command + + if (actualCommand.equalsIgnoreCase("partytp")) + { + TP(player); + } + super.onBypassFeedback(player, command); + } + + public int getPartiesInside(int zoneId)// Calculating parties inside party area. + { + int i = 0; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(locationX, locationY, locationZ)) + { + 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; + } + + public int getPlayerInside(int zoneId)// Calculating players inside party area. + { + int i = 0; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(locationX, locationY, locationZ)) + { + if (zone.getId() == zoneId) + { + for (L2Character character : zone.getCharactersInside()) + { + if ((character instanceof L2PcInstance) && (!((L2PcInstance) character).getClient().isDetached())) + { + i++; + } + } + } + } + return i; + } + + private static 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 static void proccessTP(L2PcInstance player) // Teleporting party members to zone + { + for (L2PcInstance member : player.getParty().getPartyMembers()) + { + member.teleToLocation(locationX, locationY, locationZ, 1);// Location X, Y ,Z + } + } + + private static void TP(L2PcInstance player) // 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; + } + 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, ppl);// 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 void showChatWindow(L2PcInstance player) + { + final int npcId = Config.NPC_ID_PT_TELEPORTER; + if (npcId == npcid) + { + htmContent = "data/html/mods/PartyTeleporter/PartyTeleporter.htm"; + if (htmContent != null) + { + final NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId()); + npcHtmlMessage.setHtml(htmContent); + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId())); + npcHtmlMessage.replace("%player%", player.getName());// Replaces %player% with player name on html + npcHtmlMessage.replace("%itemname%", ItemName);// Item name replace on html + npcHtmlMessage.replace("%price%", player.getParty() != null ? "" + (ItemConsumeNum * player.getParty().getMemberCount()) + "" : "0");// Price calculate replace + npcHtmlMessage.replace("%minmembers%", "" + MinPtMembers);// Mimum entry party members replace + npcHtmlMessage.replace("%allowed%", isAllowedEnter(player) ? "<font color=00FF00>allowed</font>" : "<font color=FF0000>not allowed</font>");// Condition checker replace on html + npcHtmlMessage.replace("%parties%", ShowPartiesInside ? "<font color=FFA500>Parties Inside: " + getPartiesInside(ZoneId) + "</font><br>" : "");// Parties inside + npcHtmlMessage.replace("%players%", ShowPlayersInside ? "<font color=FFA500>Players Inside: " + getPlayerInside(ZoneId) + "</font><br>" : "");// Players Inside + player.sendPacket(npcHtmlMessage); + } + + player.sendPacket(ActionFailed.STATIC_PACKET); + } + } + + private static 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; + } + return false; + } + return false; + } + +} \ No newline at end of file data/html/mods/PartyTeleporter/PartyTeleporter.htm +<html> +<title>%player%</title> +<body><center> +<center> +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 members in party: <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> +<center> +%parties% +%players% + +<table><tr> +<td><a action="bypass -h npc_%objectId%_partypt">Teleport me & My party!</td> +</tr></table> + + +<br><br> +<center> +</body></html> data/xml/npcs/36000-36099.xml +<?xml version="1.0" encoding="utf-8"?> +<list> + <npc id="36613" name="Hector" title=""> + <set name="level" val="67"/> + <set name="radius" val="8"/> + <set name="height" val="24"/> + <set name="rHand" val="128"/> + <set name="lHand" val="628"/> + <set name="type" val="L2PartyTeleporter"/> + <set name="exp" val="449"/> + <set name="sp" val="1"/> + <set name="hp" val="2295.48154"/> + <set name="mp" val="1251"/> + <set name="hpRegen" val="7.5"/> + <set name="mpRegen" val="2.7"/> + <set name="pAtk" val="624.93199"/> + <set name="pDef" val="281.55251"/> + <set name="mAtk" val="426.74754"/> + <set name="mDef" val="206.02791"/> + <set name="crit" val="4"/> + <set name="atkSpd" val="253"/> + <set name="str" val="40"/> + <set name="int" val="21"/> + <set name="dex" val="30"/> + <set name="wit" val="20"/> + <set name="con" val="43"/> + <set name="men" val="20"/> + <set name="corpseTime" val="7"/> + <set name="walkSpd" val="50"/> + <set name="runSpd" val="195"/> + <set name="dropHerbGroup" val="0"/> + <set name="attackRange" val="40"/> + <ai type="default" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" clan="door_clan;mercenary_siege_clan" clanRange="1200" canMove="true" seedable="false"/> + <skills> + <skill id="4045" level="1"/> + <skill id="4416" level="23"/> + </skills> + </npc> + </list> this is game image https://i.imgsafe.org/1622653.jpg Изменено 27 февраля, 2016 пользователем saulea90 Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
Nha 22 Опубликовано 27 февраля, 2016 Try setFile instead of setHtml in showChatWindow method Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
saulea90 0 Опубликовано 27 февраля, 2016 can you show me exact the line code cuz i'm not a java programer best ..but i know a little Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
Nha 22 Опубликовано 27 февраля, 2016 + @Override + public void showChatWindow(L2PcInstance player) + { + final int npcId = Config.NPC_ID_PT_TELEPORTER; + if (npcId == npcid) + { + htmContent = "data/html/mods/PartyTeleporter/PartyTeleporter.htm"; + if (htmContent != null) + { + final NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId()); + npcHtmlMessage.setHtml(htmContent); + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId())); + npcHtmlMessage.replace("%player%", player.getName());// Replaces %player% with player name on html + npcHtmlMessage.replace("%itemname%", ItemName);// Item name replace on html + npcHtmlMessage.replace("%price%", player.getParty() != null ? "" + (ItemConsumeNum * player.getParty().getMemberCount()) + "" : "0");// Price calculate replace + npcHtmlMessage.replace("%minmembers%", "" + MinPtMembers);// Mimum entry party members replace + npcHtmlMessage.replace("%allowed%", isAllowedEnter(player) ? "<font color=00FF00>allowed</font>" : "<font color=FF0000>not allowed</font>");// Condition checker replace on html + npcHtmlMessage.replace("%parties%", ShowPartiesInside ? "<font color=FFA500>Parties Inside: " + getPartiesInside(ZoneId) + "</font><br>" : "");// Parties inside + npcHtmlMessage.replace("%players%", ShowPlayersInside ? "<font color=FFA500>Players Inside: " + getPlayerInside(ZoneId) + "</font><br>" : "");// Players Inside + player.sendPacket(npcHtmlMessage); + } + + player.sendPacket(ActionFailed.STATIC_PACKET); + } + } Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
saulea90 0 Опубликовано 27 февраля, 2016 + @Override + public void showChatWindow(L2PcInstance player) + { + final int npcId = Config.NPC_ID_PT_TELEPORTER; + if (npcId == npcid) + { + htmContent = "data/html/mods/PartyTeleporter/PartyTeleporter.htm"; + if (htmContent != null) + { + final NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId()); + npcHtmlMessage.setHtml(htmContent); + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId())); + npcHtmlMessage.replace("%player%", player.getName());// Replaces %player% with player name on html + npcHtmlMessage.replace("%itemname%", ItemName);// Item name replace on html + npcHtmlMessage.replace("%price%", player.getParty() != null ? "" + (ItemConsumeNum * player.getParty().getMemberCount()) + "" : "0");// Price calculate replace + npcHtmlMessage.replace("%minmembers%", "" + MinPtMembers);// Mimum entry party members replace + npcHtmlMessage.replace("%allowed%", isAllowedEnter(player) ? "<font color=00FF00>allowed</font>" : "<font color=FF0000>not allowed</font>");// Condition checker replace on html + npcHtmlMessage.replace("%parties%", ShowPartiesInside ? "<font color=FFA500>Parties Inside: " + getPartiesInside(ZoneId) + "</font><br>" : "");// Parties inside + npcHtmlMessage.replace("%players%", ShowPlayersInside ? "<font color=FFA500>Players Inside: " + getPlayerInside(ZoneId) + "</font><br>" : "");// Players Inside + player.sendPacket(npcHtmlMessage); + } + + player.sendPacket(ActionFailed.STATIC_PACKET); + } + } ok ty i fixed but is not just it is some wrong html file ) like partypt but corerct is partytp Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
saulea90 0 Опубликовано 28 февраля, 2016 i have 1 more proble with showplayerinside and showpartyes inside he sayd are 0 but is not true Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
Nha 22 Опубликовано 28 февраля, 2016 Something wrong with ZoneId, i think Make sure, that players teleporting in zone, whose id specified in your config file (NpcPtZoneID) Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты