Jump to content

Recommended Posts

Posted

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");
	}

}

 

  • Like 2
  • Thanks 2
  • Upvote 5
  • 1 month later...
Posted

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;
}
  • Upvote 1
  • 2 weeks later...
Posted
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!

  • 5 months later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • i know some things from java and eclipse about coding but for sure i take one programmer to make the hard work. thank you very much for your replying 🙂
    • Forum Post:   🛡️ L2Genesis Closed Beta — Test With Us, Launch With Exclusive Rewards Join the community: https://discord.gg/mcuHsQzNCm Website: https://l2genesis.com/ Join Beta: https://cbt.l2genesis.com/     Hey everyone, We're L2Genesis — an Interlude Classic server being built with one core belief: every player matters. Not just the top clans, not just the donators — everyone. We've spent months developing, refining, and listening to community feedback. Now we're opening up our Closed Beta and we need your help to make sure this server launches rock-solid. Registration is open for one week only — after that, the doors close. Every tester who puts in the work walks into launch day with exclusive rewards that won't be available again.     Why Genesis? We're not rushing to open doors and hope for the best. We're building a community-first server where player feedback directly shapes the final product. No pay-to-win, no shortcuts — just a clean Interlude experience with thoughtful quality-of-life improvements. If you've been burned by servers that promise the world and deliver a cash shop, this one's for you. What you can expect to see on our server: - x4 rate - Player buff trade shop - Crystallization shop - Arena mode for FUN PvP     Closed Beta Rewards Rewards are tied to real participation — no freebies for just showing up. 🥉 Tier 1 The test server runs at x100 rates with a gear shop, so you won't be grinding for days just to start testing. Requirements: Register, level to S-grade, complete 3rd profession, and join one of the organized beta clans.   Launch Rewards: - Exclusive "Genesis Start" Discord rank - Beta Box — unique hat (won't be available after launch) + big-head potions, fireworks & more   Optional: Participate in the Bug Hunt for additional rewards (details below). You will have one week from CBT server launch to complete Tier 1 🥇 Tier 2 Requirements: Complete Tier 1 + participate in at least 3 events like Clan Wars, Siege and others, they will be stated during CBT in Discord. Launch Rewards: - Everything from Tier 1 - 1 Month of VIP status — quality-of-life perks handed to you for free on day one     🐛 Bug Hunt — Bonus Rewards Throughout the beta we're running a Bug Hunt — find and report bugs to earn 1 Genesis Coin (donation currency) for every confirmed bug. We'll share full details and focus areas once you're in.     Get Involved This is your chance to shape a server before it launches, not complain about it after. The testers who show up now are the ones who'll feel the difference on day one — and they'll have the exclusive rewards to prove it. Sign Up for beta test and drop in to Discord, and let's build something worth logging into. Even if you're not ready to test but you're a veteran L2 player — join the community anyway. Your experience and perspective are worth a lot to us. See you in Aden.  
    • l2jlucera the source code is not public and is not for sale. If you're going to use L2jMobius or L2jAcis, you need to know how to program or have a basic understanding, and you can ask for help from a bot, which usually won't be 100% helpful. Or you can pay a programmer to do the work for you.  
    • You need for sure some knowledge to make a good start and dont get scammed.
    • https://l2jmobiusdevclon.pp.ua/index.php
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..