Jump to content

Recommended Posts

Posted

Hey everyone,

 

I saw Fanky's code which isn't working and I coded this code from scratch.

 

Description : Every X minutes (seconds in config) an announcement appears which says how many players are online.

### Eclipse Workspace Patch 1.0
#P Coding Time!
Index: java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java	(working copy)
@@ -0,0 +1,52 @@
+/*
+ * 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 net.sf.l2j.gameserver.model.entity;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.L2World;
+
+/**
+ * 
+ * @author Debian
+ *
+ */
+
+public class AnnounceOnlinePlayers
+{
+    public static void getInstance()
+    {
+        ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
+        {
+            @Override
+            @SuppressWarnings("synthetic-access")
+            public void run()
+            {
+                Announce();
+            }
+        }, 0,Config.ANNOUNCE_ONLINE_PLAYERS_DELAY * 1000);
+     }
+    @SuppressWarnings("static-access")
+    private static void Announce()
+    {
+        int NumberofPlayers = L2World.getInstance().getAllPlayersCount();
+
+        if (NumberofPlayers == 1)
+            Announcements.getInstance().announceToAll(NumberofPlayers + " player is online.");
+        else
+            Announcements.getInstance().announceToAll(NumberofPlayers + " players are online.");
+    }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 270)
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -89,6 +89,7 @@
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.PartyMatchRoomList;
import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
+import net.sf.l2j.gameserver.model.entity.AnnounceOnlinePlayers;
import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.gameserver.model.entity.Hero;
import net.sf.l2j.gameserver.model.olympiad.Olympiad;
@@ -273,6 +274,9 @@
		if (Config.ALLOW_WEDDING)
			CoupleManager.getInstance();

+		if (Config.ALLOW_ANNOUNCE_ONLINE_PLAYERS)
+		    AnnounceOnlinePlayers.getInstance();
+		
		Util.printSection("System");
		TaskManager.getInstance();

Index: config/events.properties
===================================================================
--- config/events.properties	(revision 270)
+++ config/events.properties	(working copy)
@@ -229,4 +229,13 @@
AltLottery3NumberRate = 0.2

# How much adena receive characters who pick two or less of the winning number
-AltLottery2and1NumberPrize = 200
\ No newline at end of file
+AltLottery2and1NumberPrize = 200
+
+#=============================================================
+#                  Announce Online Players
+#=============================================================
+# Enable this feature.
+AllowAnnounceOnlinePlayers = True
+
+# Announcement Delay (in seconds)
+AnnounceOnlinePlayersDelay = 300
\ No newline at end of file
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java	(revision 270)
+++ java/net/sf/l2j/Config.java	(working copy)
@@ -262,6 +262,10 @@
	public static float ALT_LOTTERY_3_NUMBER_RATE;
	public static int ALT_LOTTERY_2_AND_1_NUMBER_PRIZE;

+	/** Announce Online Players */
+	public static boolean ALLOW_ANNOUNCE_ONLINE_PLAYERS;
+	public static int ANNOUNCE_ONLINE_PLAYERS_DELAY;
+	
	// --------------------------------------------------
	// HexID
	// --------------------------------------------------
@@ -994,6 +998,8 @@
				ALT_LOTTERY_4_NUMBER_RATE = Float.parseFloat(events.getProperty("AltLottery4NumberRate", "0.2"));
				ALT_LOTTERY_3_NUMBER_RATE = Float.parseFloat(events.getProperty("AltLottery3NumberRate", "0.2"));
				ALT_LOTTERY_2_AND_1_NUMBER_PRIZE = Integer.parseInt(events.getProperty("AltLottery2and1NumberPrize", "200"));
+				ALLOW_ANNOUNCE_ONLINE_PLAYERS = Boolean.parseBoolean(events.getProperty("AllowAnnounceOnlinePlayers", "True"));
+				ANNOUNCE_ONLINE_PLAYERS_DELAY = Integer.parseInt(events.getProperty("AnnounceOnlinePlayersDelay", "300"));
			}
			catch (Exception e)
			{

 

For any problems, pm me!

 

Kind regards,

 

Debian

Posted

Hey everyone,

 

I saw Fanky's code which isn't working and I coded this code from scratch.

 

Description : Every X minutes (seconds in config) an announcement appears which says how many players are online.

### Eclipse Workspace Patch 1.0
#P Coding Time!
Index: java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java	(working copy)
@@ -0,0 +1,52 @@
+/*
+ * 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 net.sf.l2j.gameserver.model.entity;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.L2World;
+
+/**
+ * 
+ * @author Debian
+ *
+ */
+
+public class AnnounceOnlinePlayers
+{
+    public static void getInstance()
+    {
+        ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
+        {
+            @Override
+            @SuppressWarnings("synthetic-access")
+            public void run()
+            {
+                Announce();
+            }
+        }, 0,Config.ANNOUNCE_ONLINE_PLAYERS_DELAY * 1000);
+     }
+    @SuppressWarnings("static-access")
+    private static void Announce()
+    {
+        int NumberofPlayers = L2World.getInstance().getAllPlayersCount();
+
+        if (NumberofPlayers == 1)
+            Announcements.getInstance().announceToAll(NumberofPlayers + " player is online.");
+        else
+            Announcements.getInstance().announceToAll(NumberofPlayers + " players are online.");
+    }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 270)
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -89,6 +89,7 @@
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.PartyMatchRoomList;
import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
+import net.sf.l2j.gameserver.model.entity.AnnounceOnlinePlayers;
import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.gameserver.model.entity.Hero;
import net.sf.l2j.gameserver.model.olympiad.Olympiad;
@@ -273,6 +274,9 @@
		if (Config.ALLOW_WEDDING)
			CoupleManager.getInstance();

+		if (Config.ALLOW_ANNOUNCE_ONLINE_PLAYERS)
+		    AnnounceOnlinePlayers.getInstance();
+		
		Util.printSection("System");
		TaskManager.getInstance();

Index: config/events.properties
===================================================================
--- config/events.properties	(revision 270)
+++ config/events.properties	(working copy)
@@ -229,4 +229,13 @@
AltLottery3NumberRate = 0.2

# How much adena receive characters who pick two or less of the winning number
-AltLottery2and1NumberPrize = 200
\ No newline at end of file
+AltLottery2and1NumberPrize = 200
+
+#=============================================================
+#                  Announce Online Players
+#=============================================================
+# Enable this feature.
+AllowAnnounceOnlinePlayers = True
+
+# Announcement Delay (in seconds)
+AnnounceOnlinePlayersDelay = 300
\ No newline at end of file
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java	(revision 270)
+++ java/net/sf/l2j/Config.java	(working copy)
@@ -262,6 +262,10 @@
	public static float ALT_LOTTERY_3_NUMBER_RATE;
	public static int ALT_LOTTERY_2_AND_1_NUMBER_PRIZE;

+	/** Announce Online Players */
+	public static boolean ALLOW_ANNOUNCE_ONLINE_PLAYERS;
+	public static int ANNOUNCE_ONLINE_PLAYERS_DELAY;
+	
	// --------------------------------------------------
	// HexID
	// --------------------------------------------------
@@ -994,6 +998,8 @@
				ALT_LOTTERY_4_NUMBER_RATE = Float.parseFloat(events.getProperty("AltLottery4NumberRate", "0.2"));
				ALT_LOTTERY_3_NUMBER_RATE = Float.parseFloat(events.getProperty("AltLottery3NumberRate", "0.2"));
				ALT_LOTTERY_2_AND_1_NUMBER_PRIZE = Integer.parseInt(events.getProperty("AltLottery2and1NumberPrize", "200"));
+				ALLOW_ANNOUNCE_ONLINE_PLAYERS = Boolean.parseBoolean(events.getProperty("AllowAnnounceOnlinePlayers", "True"));
+				ANNOUNCE_ONLINE_PLAYERS_DELAY = Integer.parseInt(events.getProperty("AnnounceOnlinePlayersDelay", "300"));
			}
			catch (Exception e)
			{

 

For any problems, pm me!

 

Kind regards,

 

Debian

Φοβερο +1 απο μενα :)

  • 5 weeks later...
  • 1 month later...
  • 5 weeks later...
Posted

Hey everyone,

 

I saw Fanky's code which isn't working and I coded this code from scratch.

 

Description : Every X minutes (seconds in config) an announcement appears which says how many players are online.

### Eclipse Workspace Patch 1.0
#P Coding Time!
Index: java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java	(working copy)
@@ -0,0 +1,52 @@
+/*
+ * 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 net.sf.l2j.gameserver.model.entity;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.L2World;
+
+/**
+ * 
+ * @author Debian
+ *
+ */
+
+public class AnnounceOnlinePlayers
+{
+    public static void getInstance()
+    {
+        ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
+        {
+            @Override
+            @SuppressWarnings("synthetic-access")
+            public void run()
+            {
+                Announce();
+            }
+        }, 0,Config.ANNOUNCE_ONLINE_PLAYERS_DELAY * 1000);
+     }
+    @SuppressWarnings("static-access")
+    private static void Announce()
+    {
+        int NumberofPlayers = L2World.getInstance().getAllPlayersCount();
+
+        if (NumberofPlayers == 1)
+            Announcements.getInstance().announceToAll(NumberofPlayers + " player is online.");
+        else
+            Announcements.getInstance().announceToAll(NumberofPlayers + " players are online.");
+    }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 270)
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -89,6 +89,7 @@
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.PartyMatchRoomList;
import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
+import net.sf.l2j.gameserver.model.entity.AnnounceOnlinePlayers;
import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.gameserver.model.entity.Hero;
import net.sf.l2j.gameserver.model.olympiad.Olympiad;
@@ -273,6 +274,9 @@
		if (Config.ALLOW_WEDDING)
			CoupleManager.getInstance();

+		if (Config.ALLOW_ANNOUNCE_ONLINE_PLAYERS)
+		    AnnounceOnlinePlayers.getInstance();
+		
		Util.printSection("System");
		TaskManager.getInstance();

Index: config/events.properties
===================================================================
--- config/events.properties	(revision 270)
+++ config/events.properties	(working copy)
@@ -229,4 +229,13 @@
AltLottery3NumberRate = 0.2

# How much adena receive characters who pick two or less of the winning number
-AltLottery2and1NumberPrize = 200
\ No newline at end of file
+AltLottery2and1NumberPrize = 200
+
+#=============================================================
+#                  Announce Online Players
+#=============================================================
+# Enable this feature.
+AllowAnnounceOnlinePlayers = True
+
+# Announcement Delay (in seconds)
+AnnounceOnlinePlayersDelay = 300
\ No newline at end of file
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java	(revision 270)
+++ java/net/sf/l2j/Config.java	(working copy)
@@ -262,6 +262,10 @@
	public static float ALT_LOTTERY_3_NUMBER_RATE;
	public static int ALT_LOTTERY_2_AND_1_NUMBER_PRIZE;

+	/** Announce Online Players */
+	public static boolean ALLOW_ANNOUNCE_ONLINE_PLAYERS;
+	public static int ANNOUNCE_ONLINE_PLAYERS_DELAY;
+	
	// --------------------------------------------------
	// HexID
	// --------------------------------------------------
@@ -994,6 +998,8 @@
				ALT_LOTTERY_4_NUMBER_RATE = Float.parseFloat(events.getProperty("AltLottery4NumberRate", "0.2"));
				ALT_LOTTERY_3_NUMBER_RATE = Float.parseFloat(events.getProperty("AltLottery3NumberRate", "0.2"));
				ALT_LOTTERY_2_AND_1_NUMBER_PRIZE = Integer.parseInt(events.getProperty("AltLottery2and1NumberPrize", "200"));
+				ALLOW_ANNOUNCE_ONLINE_PLAYERS = Boolean.parseBoolean(events.getProperty("AllowAnnounceOnlinePlayers", "True"));
+				ANNOUNCE_ONLINE_PLAYERS_DELAY = Integer.parseInt(events.getProperty("AnnounceOnlinePlayersDelay", "300"));
			}
			catch (Exception e)
			{

 

For any problems, pm me!

 

Kind regards,

 

Debian

 

where to add this code to make it works :D ? :poker face:

  • 2 months 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

    • We've added 5% discounts for bulk purchases of Google accounts for orders of 300 or more, and 10% for orders of 500 or more. The discount is applied automatically when you place your order! The discount is indicated in the product title and description for each category.  
    • 🎄 CHRISTMAS EVENT 🎄   ‼️ Information and details: https://forum.l2harbor.com/threads/rozhdestvenskie-xlopoty-christmas-chores.9430/post-171464
    • METATG.ORG Direct Telegram Service Provider A bonus of +7% on every order! *We add 7% more followers than your ordered amount to proactively cover potential drops and guarantee you an honest result." Telegram Followers - Price per 1000 SUBSCRIBERS Subscribers 3 days - $0.10 ~ 8 RUB Subscribers. Daily Completion: 200,000,000 Subscribers 7 days - $0.17 ~ 13.6 RUB Subscribers. Daily Completion: 200,000,000 Subscribers 14 days - $0.20 ~ 16 RUB Subscribers. Daily Completion: 200,000,000 Subscribers 30 days - $0.30 ~ 24 RUB Subscribers. Daily Completion: 200,000,000 Subscribers 60 days - $0.40 ~ 32 RUB Subscribers, 14-day guarantee. Daily Completion: 200,000,000 Subscribers 90 days (Super Fast) - $0.50 ~ 40 RUB Subscribers, 14-day guarantee. Daily Completion: 200,000,000 Subscribers 120 days (Super Fast) - $0.60 ~ 48 RUB Subscribers, 14-day guarantee. Daily Completion: 200,000,000 Subscribers Lifetime (Super Fast) - $0.70 ~ 56 RUB Lifetime Subscribers. 14-day guarantee. Daily Completion: 200,000,000 Telegram Services - Price per 1000 Post Views - $0.06 ~ 5 RUB Reactions - $0.08 ~ 6.5 RUB Bot Starts - $0.10 ~ 8 RUB Bot Starts with referrals - $0.15 ~ 12 RUB DISCOUNTS and CASHBACK for large volumes Direct Supplier. We work from our own accounts with our own software! High execution speed. Multiple payment methods. We work 24/7! Additional discounts are discussed for volumes starting from $1000 per day. SUPPORT 24/7 - TELEGRAM WEBSITE 24/7 - METATG.ORG
    • Added: a brand-new default dashboard template. You can now add multiple game/login server builds. Full support for running both PTS & L2J servers simultaneously, with switching between them. Payment systems: added OmegaPay and Pally (new PayPal-style API). Account history now stores everything: donations, items delivered to characters, referrals, transfers between game accounts, and coin transfers to another master account. Personal Promo Code System: you can create a promo code and assign it to a user or promoter. When donating, a player can enter this promo code to receive bonus coins, and the promo code owner also receives a bonus — all fully configurable in the admin panel.     Look demo site: demo
  • Topics

×
×
  • 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