[HELP] Java Script Load but NPC dont work
Posted: Thu Jan 19, 2012 2:08 am
Hi People,
First of all I want to say thank you for the great job that you do in the forum, and for give us the possibility to learn more about this excellent game and teach us in the development of parts and addons.
Well the problem that I have is the following, Im using the NPC from viewtopic.php?f=13&t=21903 and seems like is not for Hellbound, cause when i try to compile it the Gameserver show me some errors, I solved it, and I try to put it working, I touch it a lot, and I obtain the possibility to put the NPC on server I click on them and show me the main.html but If i click on Show List nothing happend, the NPC windows is close and nothing more, I saw in the post that has a .diff file, what is it? Is necessary put it in some place or what is it?
I want the NPC to give to users complete the 2 necessary quest to do the Subclass into the NPC manager for each class, without need to take complete the fate whisper and mimir's elixir, so I need these 2 quest into the NPC to put it as complete.
If you have another way to put complete these 2 quest for users that click into an NPC, will be welcome.
I'm using the CT1_5 rev, and gameserver code from SVN for the same rev.
These code modified for Hellbound is
Any help will be welcome, thanks for read and sorry for disturb you.
Regards!
First of all I want to say thank you for the great job that you do in the forum, and for give us the possibility to learn more about this excellent game and teach us in the development of parts and addons.
Well the problem that I have is the following, Im using the NPC from viewtopic.php?f=13&t=21903 and seems like is not for Hellbound, cause when i try to compile it the Gameserver show me some errors, I solved it, and I try to put it working, I touch it a lot, and I obtain the possibility to put the NPC on server I click on them and show me the main.html but If i click on Show List nothing happend, the NPC windows is close and nothing more, I saw in the post that has a .diff file, what is it? Is necessary put it in some place or what is it?
I want the NPC to give to users complete the 2 necessary quest to do the Subclass into the NPC manager for each class, without need to take complete the fate whisper and mimir's elixir, so I need these 2 quest into the NPC to put it as complete.
If you have another way to put complete these 2 quest for users that click into an NPC, will be welcome.
I'm using the CT1_5 rev, and gameserver code from SVN for the same rev.
These code modified for Hellbound is
Code: Select all
/* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */package custom.QuestSeller; import net.sf.l2j.gameserver.cache.HtmCache;import net.sf.l2j.gameserver.datatables.ItemTable;import net.sf.l2j.gameserver.instancemanager.QuestManager;import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;import net.sf.l2j.gameserver.model.quest.Quest;import net.sf.l2j.gameserver.model.quest.QuestState;import net.sf.l2j.gameserver.model.quest.State;import net.sf.l2j.gameserver.templates.L2Item; /** * Quest seller Npc AI. * @author Zoey76 */public final class QuestSeller extends Quest{ /** * Quest name. */ private static final String qn = "QuestSeller"; /** * NPC Id, this NPC will sell the quests. */ private static final int _questSellerNpcId = 90000; /** * Festival Adena, coin used to buy quests. */ private static final int _coin = 57; /** * Template for the coin used. */ private static final L2Item coinItemTemplate = ItemTable.getInstance().getTemplate(_coin); /** * Multidimensional array containing the quests and it's price in {@code _coin} item. */ private static final int[][] _questIdsCost = { { 136, 20 }, //More Than Meets the Eye, 20 Festival Adena { 631, 15 }, //Delicious Top Choice Meat, 15 Festival Adena { 19, 10 }, //Delicious Top Choice Meat, 15 Festival Adena { 135, 150000000 }, //Mimir's { 134, 150000000 } //Fate }; @Override public String onAdvEvent(String event, L2NpcInstance npc, L2PcInstance player) { String htmltext = event; if (event.equalsIgnoreCase("ShowList")) { //Player requested the quest list. String path="data/scripts/custom/QuestSeller/show.htm"; htmltext = HtmCache.getInstance().getHtm(path); if ((htmltext != null) && !htmltext.isEmpty()) { htmltext = htmltext.replaceAll("QUEST_LIST", buildQuestList(_questIdsCost)); } else { htmltext = "questListNoAvailable.htm"; } } else if (event.startsWith("QuestId_")) { QuestState st = player.getQuestState(qn); if (st == null) { st = this.newQuestState(player); } try { int questId = Integer.parseInt(event.substring(8)); int questCost = getQuestCost(_questIdsCost, questId); if ((questCost > -1) && (st.getQuestItemsCount(_coin) >= questCost)) { Quest quest = QuestManager.getInstance().getQuest(questId); QuestState newQuestState = player.getQuestState(quest.getName()); if (newQuestState == null) { newQuestState = quest.newQuestState(player); } if (newQuestState.isCompleted()) { htmltext = "alreadyFinishedThisQuest.htm"; } else { newQuestState.setState(State.COMPLETED); st.takeItems(_coin, questCost); //Show thanks message. htmltext = HtmCache.getInstance().getHtm("data/scripts/custom/QuestSeller/thanksForBuying.htm"); if ((htmltext != null) && !htmltext.isEmpty()) { htmltext = htmltext.replaceAll("QUEST_NAME", quest.getDescr()); } else { //Couldm't find thanks html. htmltext = "questNoAvailable.htm"; //TODO: Change for a proper message. } } } else if (questCost <= -1) { //Couln't find right quest price. htmltext = "questNoAvailable.htm"; } else { //Player doesn't have enough coins to buy this quest. htmltext = "notEnoughCoins.htm"; } } catch (Exception e) { //The link to the quest is wrong. htmltext = "questNoAvailable.htm"; } } return htmltext; } @Override public String onFirstTalk(L2NpcInstance npc, L2PcInstance player) { return "<html><body>Quest Seller:<br>Hello there!<br>I have what you need, but everything has a price<br>Come closer and check what precious goods I have to offer!<br><a action=\"bypass -h Quest QuestSeller ShowList\">Show me please.</a><br><a action=\"bypass -h Quest QuestSeller leave.htm\">I'll leave now.</a></body></html>"; } private String buildQuestList(int[][] questIdCost) { String questList = ""; for (int[] qIdCost : questIdCost) { Quest quest = QuestManager.getInstance().getQuest(qIdCost[0]); if (quest != null) { String itemName = qIdCost[1] + " " + coinItemTemplate.getName(); if (qIdCost[1] > 1) { itemName = itemName + "(s)"; } questList = questList + "<a action=\"bypass -h Quest QuestSeller QuestId_" + qIdCost[0] + "\">\"" + quest.getDescr() + " [" + itemName + "]\"</a><br>"; } } return questList; } private int getQuestCost(int[][] questIdCost, int questId) { int questCost = -150000000; for (int[] qIdCost : questIdCost) { if (qIdCost[0] == questId) { questCost = qIdCost[1]; break; } } return questCost; } public QuestSeller(int questId, String name, String descr) { super(questId, name, descr); addStartNpc(_questSellerNpcId); addTalkId(_questSellerNpcId); addFirstTalkId(_questSellerNpcId); } public static void main(String[] args) { new QuestSeller(-1, qn, "Custom"); }}
Regards!