-Invoke Posted March 29, 2020 Posted March 29, 2020 Hey guys if you are doing a project from the scratch and looking for a way to connect community board with the htmls i think this is a good way to do it even though there are many ways! I am just giving the idea here so please don't flame with better codes and stuff :) I will do this in l2j mobious H5, i think it works mostly in all packs but let me know if it does not. 1) So you basically you are gonna create a new custom script that will extend Quest, in this case I named it CBnpcs.java (scripts/custom/CommunityNpcs/CBnpcs.java) 2) Set the ids of our custom npcs 3) You have to add them on firsttalk , talk, startnpc each one separately just like bellow 4) Then the link where you have stored your htmls 5) So if you want to create more npcs connecting them to CB you can simply copy and paste the else ifs and set more ids 6) Some packs i think require the scripts to be registered on scripts.cfg so do that as well if you own such pack package custom.CommunityNpcs; import com.l2jmobius.gameserver.cache.HtmCache; import com.l2jmobius.gameserver.handler.CommunityBoardHandler; import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.quest.Quest; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; /** * @author -Invoke */ public class CBnpcs extends Quest { private static final int Merchant = 36621; private static final int Gatekeeper = 36622; public CBnpcs(int questId) { super(questId); addFirstTalkId(Merchant); addFirstTalkId(Gatekeeper); // addTalkId(Merchant); addTalkId(Gatekeeper); // addStartNpc(Merchant); addStartNpc(Gatekeeper); } @Override public String onFirstTalk(L2Npc npc, L2PcInstance player) { final int npcId = npc.getId(); String mainhtml = HtmCache.getInstance().getHtm(player, "data/html/CommunityBoard/Custom/main.html"); if (npcId == Merchant) { String html = HtmCache.getInstance().getHtm(player, "data/html/CommunityBoard/Custom/merchant/main.html"); CommunityBoardHandler.separateAndSend(html, player); } else if (npcId == Gatekeeper) { String html = HtmCache.getInstance().getHtm(player, "data/html/CommunityBoard/Custom/gatekeeper/main.html"); CommunityBoardHandler.separateAndSend(html, player); } CommunityBoardHandler.separateAndSend(mainhtml, player); return ""; } public static void main(final String[] args) { new CBnpcs(-1); LOGGER.info("COMMYNITY NPCS LOADED"); } } 2 2 5 Quote
BabayG Posted March 30, 2020 Posted March 30, 2020 Gj keep sharing. Forum needs topics like this Quote
-Invoke Posted March 30, 2020 Author Posted March 30, 2020 6 hours ago, JohnBoy13 said: Gj keep sharing. Forum needs topics like this Thank you! i will do my best! :) Quote
StinkyMadness Posted May 27, 2020 Posted May 27, 2020 Some clean/short of onFirstTalk method public String onFirstTalk(L2Npc npc, L2PcInstance player) { String path = "data/html/CommunityBoard/Custom/main.html"; switch(npc.getId()) { case Merchant: path = "data/html/CommunityBoard/Custom/merchant/main.html"; break; case Gatekeeper: path = "data/html/CommunityBoard/Custom/gatekeeper/main.html"; break; } CommunityBoardHandler.separateAndSend(HtmCache.getInstance().getHtm(player, path), player); return null; } 1 Quote
-Invoke Posted June 6, 2020 Author Posted June 6, 2020 On 5/27/2020 at 10:59 PM, StinkyMadness said: Some clean/short of onFirstTalk method public String onFirstTalk(L2Npc npc, L2PcInstance player) { String path = "data/html/CommunityBoard/Custom/main.html"; switch(npc.getId()) { case Merchant: path = "data/html/CommunityBoard/Custom/merchant/main.html"; break; case Gatekeeper: path = "data/html/CommunityBoard/Custom/gatekeeper/main.html"; break; } CommunityBoardHandler.separateAndSend(HtmCache.getInstance().getHtm(player, path), player); return null; } yep ! good onee! Quote
disorder25 Posted December 3, 2020 Posted December 3, 2020 can anyone adapt it to l2j Hi5? If yes it will be appreciated. Thank you. Quote
amaromorte Posted August 18, 2022 Posted August 18, 2022 Cool, but how do you connect that with html buttons? Quote
Recommended Posts
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.