Jump to content

[Share] Online players vcmd via html page


Recommended Posts

Howdy,i'm here to share something today.

I know showing online player count to html page is useless but hey its just an idea :D

Have Fun.

 

Index: java/config/l2jmods.properties
===================================================================
--- java/config/l2jmods.properties	(revision 4652)
+++ java/config/l2jmods.properties	(working copy)
@@ -348,6 +348,9 @@
# variables: $killer, $target
AnnouncePvpMsg = $killer has defeated $target

+# Show online players vcmd
+# Default: False
+ShowOnlinePlayers = False

# ---------------------------------------------------------------------------
# Chat Moderation
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java	(revision 4652)
+++ java/com/l2jserver/Config.java	(working copy)
@@ -1018,6 +1018,8 @@
	//chatfilter
	public static ArrayList<String>	FILTER_LIST;

+	public static boolean SHOW_ONLINE_PLAYERS;
+	
	/**
	 * This class initializes all global variables for configuration.<br>
	 * If the key doesn't appear in properties file, a default value is set by this class.
@@ -2442,6 +2444,7 @@
					ANNOUNCE_PK_MSG = L2JModSettings.getProperty("AnnouncePkMsg", "$killer has slaughtered $target");
					ANNOUNCE_PVP_MSG = L2JModSettings.getProperty("AnnouncePvpMsg", "$killer has defeated $target");

+					SHOW_ONLINE_PLAYERS = Boolean.parseBoolean(L2JModSettings.getProperty("ShowOnlinePlayers","False"));
					L2JMOD_CHAT_ADMIN = Boolean.parseBoolean(L2JModSettings.getProperty("ChatAdmin", "false"));

					L2JMOD_MULTILANG_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("MultiLangEnable", "false"));
#P L2J_DataPack
Index: data/scripts/handlers/MasterHandler.java
===================================================================
--- data/scripts/handlers/MasterHandler.java	(revision 8046)
+++ data/scripts/handlers/MasterHandler.java	(working copy)
@@ -245,6 +245,7 @@
import handlers.voicedcommandhandlers.ChatAdmin;
import handlers.voicedcommandhandlers.Debug;
import handlers.voicedcommandhandlers.Lang;
+import handlers.voicedcommandhandlers.Online;
import handlers.voicedcommandhandlers.TvTVoicedInfo;
import handlers.voicedcommandhandlers.Wedding;
import handlers.voicedcommandhandlers.stats;
@@ -546,6 +547,8 @@
			VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Banking());
		if (Config.TVT_ALLOW_VOICED_COMMAND)
			VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new TvTVoicedInfo());
+		if (Config.SHOW_ONLINE_PLAYERS)
+			VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Online());
		if (Config.L2JMOD_CHAT_ADMIN)
			VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new ChatAdmin());
		if (Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW)
Index: data/html/mods/online/OnlineStatus.htm
===================================================================
--- data/html/mods/online/OnlineStatus.htm	(revision 0)
+++ data/html/mods/online/OnlineStatus.htm	(revision 0)
@@ -0,0 +1,4 @@
+<html><title>Online players status</title>
+<body><center>There are %playernumber% players online.<br>
+<font color="333333">by Voqus</font><br>
+<button value="Exit" action="bypass -h Close" width=45 height=25 back="L2UI_CT1.Button_DF_Down" fore="L2UI_ct1.button_df">
+</center></body></html>
Index: data/scripts/handlers/voicedcommandhandlers/Online.java
===================================================================
--- data/scripts/handlers/voicedcommandhandlers/Online.java	(revision 0)
+++ data/scripts/handlers/voicedcommandhandlers/Online.java	(revision 0)
@@ -0,0 +1,44 @@
+package handlers.voicedcommandhandlers;
+
+import com.l2jserver.gameserver.cache.HtmCache;
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * @author Voqus
+ */
+
+public class Online implements IVoicedCommandHandler
+{
+	public static final String[] VOICED_COMMANDS = { "online" };
+
+	private static final boolean USE_STATIC_HTML = true;
+	private static final String HTML_LINK = HtmCache.getInstance().getHtm(null, "data/html/mods/online/OnlineStatus.htm");
+	
+	public boolean useVoicedCommand(String command, L2PcInstance player, String params)
+	{
+		String htmContent = (USE_STATIC_HTML && !HTML_LINK.isEmpty()) ? HTML_LINK :
+		HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/mods/online/OnlineStatus.htm");
+		
+		if(command.equalsIgnoreCase("online"))
+		{
+			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
+			
+			npcHtmlMessage.setHtml(htmContent);
+			npcHtmlMessage.replace("%playernumber%", String.valueOf(L2World.getInstance().getAllPlayers().size()));
+			player.sendPacket(npcHtmlMessage);
+			}
+			else
+			{
+				player.sendPacket(ActionFailed.STATIC_PACKET);
+			}
+		return true;
+	}
+	
+	public String[] getVoicedCommandList()
+	{
+		return VOICED_COMMANDS;
+	}
+}

 

Credits: me

Link to comment
Share on other sites

good job mate but it is uselless :>

 

Is not useless, if you want to see the players online without the community board because it makes lag, so, thats a light code who dont make lag and its useful for me. Any1 haves a different way to use it.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock