Nobless NPC
Posted: Wed Oct 20, 2010 2:05 pm
Hey guys, can someone give me an NPC that does me noble for a Caradine letter?
Thanks
Thanks
Code: Select all
### Eclipse Workspace Patch 1.0#P datapack_developmentIndex: data/scripts/custom/FreeNoble/FreeNoble.java===================================================================--- data/scripts/custom/FreeNoble/FreeNoble.java (revision 0)+++ data/scripts/custom/FreeNoble/FreeNoble.java (revision 0)@@ -0,0 +1,78 @@+package custom.FreeNoble;++import com.l2jserver.gameserver.instancemanager.QuestManager;+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.quest.QuestState;++/**+ * @author LasTravel+ */+ +public class FreeNoble extends Quest+{+ private static final int NPCID = 700001;+ private static final int LevelMin = 80;+ private static final int ItemId = 7678; //Caradine's Letter + private static final int Amount = 1;+ + private static final String qn = "FreeNoble";+ + public FreeNoble(int questId, String name, String descr)+ {+ super(questId, name, descr);+ addStartNpc(NPCID);+ addTalkId(NPCID);+ }+ + @Override+ public String onTalk(L2Npc npc, L2PcInstance player)+ {+ String htmltext ="";+ QuestState st = player.getQuestState(getName());+ if (st == null)+ {+ Quest q = QuestManager.getInstance().getQuest(getName());+ st = q.newQuestState(player);+ }+ if (npc.getNpcId() == NPCID)+ htmltext = "1.htm";+ return htmltext;+ }+ + private boolean CheckCondition(L2PcInstance player)+ {+ if (player == null)+ return false;+ + else if (player.isHero() || player.isNoble())+ return false;+ else if (player.getLevel() < LevelMin)+ return false;+ else if (!(player.getQuestState(qn).getQuestItemsCount(ItemId) >= Amount))+ return false;+ else+ return true;+ }+ + @Override+ public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)+ {+ //Give Noble Status+ if (event.equalsIgnoreCase("getnoble"))+ if (CheckCondition(player))+ { + player.getQuestState(qn).takeItems(ItemId, Amount);+ player.setNoble(true);+ player.sendMessage("Congrats you are noble now!");+ } + else+ player.sendMessage("You can't use this, go away!");+ return "";+ }+ + public static void main(String[] args)+ {+ new FreeNoble(-1, qn, "custom");+ }+}Index: data/scripts/custom/FreeNoble/1.htm===================================================================--- data/scripts/custom/FreeNoble/1.htm (revision 0)+++ data/scripts/custom/FreeNoble/1.htm (revision 0)@@ -0,0 +1,5 @@+<html>+<body>+<a action="bypass -h Quest FreeNoble getnoble">TEST</a><br>+</body>+</html>\ No newline at end of file
Should i do "Apply patch" and copy from clipboard?LasTravel wrote:Create the default htm for the npc 700001 and done:
Code: Select all
### Eclipse Workspace Patch 1.0#P datapack_developmentIndex: data/scripts/custom/FreeNoble/FreeNoble.java===================================================================--- data/scripts/custom/FreeNoble/FreeNoble.java (revision 0)+++ data/scripts/custom/FreeNoble/FreeNoble.java (revision 0)@@ -0,0 +1,78 @@+package custom.FreeNoble;++import com.l2jserver.gameserver.instancemanager.QuestManager;+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.quest.QuestState;++/**+ * @author LasTravel+ */+ +public class FreeNoble extends Quest+{+ private static final int NPCID = 700001;+ private static final int LevelMin = 80;+ private static final int ItemId = 7678; //Caradine's Letter + private static final int Amount = 1;+ + private static final String qn = "FreeNoble";+ + public FreeNoble(int questId, String name, String descr)+ {+ super(questId, name, descr);+ addStartNpc(NPCID);+ addTalkId(NPCID);+ }+ + @Override+ public String onTalk(L2Npc npc, L2PcInstance player)+ {+ String htmltext ="";+ QuestState st = player.getQuestState(getName());+ if (st == null)+ {+ Quest q = QuestManager.getInstance().getQuest(getName());+ st = q.newQuestState(player);+ }+ if (npc.getNpcId() == NPCID)+ htmltext = "1.htm";+ return htmltext;+ }+ + private boolean CheckCondition(L2PcInstance player)+ {+ if (player == null)+ return false;+ + else if (player.isHero() || player.isNoble())+ return false;+ else if (player.getLevel() < LevelMin)+ return false;+ else if (!(player.getQuestState(qn).getQuestItemsCount(ItemId) >= Amount))+ return false;+ else+ return true;+ }+ + @Override+ public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)+ {+ //Give Noble Status+ if (event.equalsIgnoreCase("getnoble"))+ if (CheckCondition(player))+ { + player.getQuestState(qn).takeItems(ItemId, Amount);+ player.setNoble(true);+ player.sendMessage("Congrats you are noble now!");+ } + else+ player.sendMessage("You can't use this, go away!");+ return "";+ }+ + public static void main(String[] args)+ {+ new FreeNoble(-1, qn, "custom");+ }+}Index: data/scripts/custom/FreeNoble/1.htm===================================================================--- data/scripts/custom/FreeNoble/1.htm (revision 0)+++ data/scripts/custom/FreeNoble/1.htm (revision 0)@@ -0,0 +1,5 @@+<html>+<body>+<a action="bypass -h Quest FreeNoble getnoble">TEST</a><br>+</body>+</html>\ No newline at end of file
Hey.LasTravel wrote:Don't forget add it to scripts.cfg
Why you do one request if you don't know what do with it?returNix wrote:Hey.LasTravel wrote:Don't forget add it to scripts.cfg
If i understood right, i need to open a directory at gameserver\data\scripts\custom
named freenoble, put there the 1.htm file,
open scripts.cfg
write there:
custom/freenoble/1.htm
double click at caradine letter in-game and im noble ?
Code: Select all
<a action="bypass -h npc_%objectId%_Quest FreeNoble">FreeNoble</a><br>
The allowed range is from 1 to 65553 :XLasTravel wrote:Why you do one request if you don't know what do with it?returNix wrote:Hey.LasTravel wrote:Don't forget add it to scripts.cfg
If i understood right, i need to open a directory at gameserver\data\scripts\custom
named freenoble, put there the 1.htm file,
open scripts.cfg
write there:
custom/freenoble/1.htm
double click at caradine letter in-game and im noble ?
1- Copy the folder FreeNoble to data/scripts/custom/, then open scripts.cfg and add custom/FreeNoble/FreeNoble.java
2- Create one npc with id 700001
3- Create the default html for the npc 700001 and put it on data/html/default
Add this link on the default html
Code: Select all
<a action="bypass -h npc_%objectId%_Quest FreeNoble">FreeNoble</a><br>
The allowed range is from 1 to 65553 :XLasTravel wrote:Why you do one request if you don't know what do with it?returNix wrote:Hey.LasTravel wrote:Don't forget add it to scripts.cfg
If i understood right, i need to open a directory at gameserver\data\scripts\custom
named freenoble, put there the 1.htm file,
open scripts.cfg
write there:
custom/freenoble/1.htm
double click at caradine letter in-game and im noble ?
1- Copy the folder FreeNoble to data/scripts/custom/, then open scripts.cfg and add custom/FreeNoble/FreeNoble.java
2- Create one npc with id 700001
3- Create the default html for the npc 700001 and put it on data/html/default
Add this link on the default html
Code: Select all
<a action="bypass -h npc_%objectId%_Quest FreeNoble">FreeNoble</a><br>