Skip to content

[Share] Announcements System

Featured Replies

Hello, I thought to add announcements in my server and I did by this way.

 

I am still newbie in java* so I don't know if works correct. It's really easy, but I do practice.

 

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(revision 9)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -23,6 +23,7 @@
import net.sf.l2j.gameserver.datatables.MapRegionTable;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.datatables.SkillTable.FrequentSkill;
+import net.sf.l2j.gameserver.instancemanager.CastleManager;
import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
import net.sf.l2j.gameserver.instancemanager.CoupleManager;
import net.sf.l2j.gameserver.instancemanager.DimensionalRiftManager;
@@ -34,6 +35,7 @@
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.gameserver.model.entity.ClanHall;
import net.sf.l2j.gameserver.model.entity.Couple;
import net.sf.l2j.gameserver.model.entity.Siege;
@@ -110,6 +112,7 @@
			activeChar.sendPacket(new PledgeSkillList(activeChar.getClan()));
			notifyClanMembers(activeChar);
			notifySponsorOrApprentice(activeChar);
+			Announcements(activeChar);

			// Add message at connexion if clanHall not paid.
			ClanHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan());
@@ -250,6 +253,35 @@
			activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
	}

+	public static void Announcements(L2PcInstance activeChar)
+	{
+		if (activeChar.isHero())
+		{
+			Announcements.announceToAll("Hero "+activeChar.getName()+" has been logged in.");
+		}
+		
+		/**
+		 * 
+		 * if (activeChar.isVip())
+		 * {
+		 *     Announcements.announceToAll("VIP "+activeChar.getName()+" has been logged in.");
+		 * }
+		 * 
+		 */
+					
+		L2Clan clan = activeChar.getClan();
+
+	        if (clan != null)
+	        {
+	            if (clan.hasCastle())
+	            {
+	                Castle castle = CastleManager.getInstance().getCastleById(clan.getCastleId());
+	                if ((castle != null) && (activeChar.getObjectId() == clan.getLeaderId()))
+	                    Announcements.announceToAll("Lord " + activeChar.getName() + " ruler of " + castle.getName() + " castle is now online!");
+	            }
+	        }
+	}
+	
	private static void engage(L2PcInstance cha)
	{
		int _chaid = cha.getObjectId();

 

VIP has /** because VIP system is not implemented.

 

This code includes : Hero, VIP, Castle Lord announcements.

 

Coded on aCis, have fun!

so if some1 is Hero and owner of a castle (leader) we will get 2 announcments since there are no "return;" in your mothod !

 

Good try .. keep trying

  • Author

so if some1 is Hero and owner of a castle (leader) we will get 2 announcments since there are no "return;" in your mothod !

 

Good try .. keep trying

Thanks but where I have to add "return;" ?

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(revision 9)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -23,6 +23,7 @@
import net.sf.l2j.gameserver.datatables.MapRegionTable;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.datatables.SkillTable.FrequentSkill;
+import net.sf.l2j.gameserver.instancemanager.CastleManager;
import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
import net.sf.l2j.gameserver.instancemanager.CoupleManager;
import net.sf.l2j.gameserver.instancemanager.DimensionalRiftManager;
@@ -34,6 +35,7 @@
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.gameserver.model.entity.ClanHall;
import net.sf.l2j.gameserver.model.entity.Couple;
import net.sf.l2j.gameserver.model.entity.Siege;
@@ -110,6 +112,7 @@
			activeChar.sendPacket(new PledgeSkillList(activeChar.getClan()));
			notifyClanMembers(activeChar);
			notifySponsorOrApprentice(activeChar);
+			Announcements(activeChar);

			// Add message at connexion if clanHall not paid.
			ClanHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan());
@@ -250,6 +253,35 @@
			activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
	}

+	public static void Announcements(L2PcInstance activeChar)
+	{
+		if (activeChar.isHero())
+		{
+			Announcements.announceToAll("Hero "+activeChar.getName()+" has been logged in.");
+                       return;
+		}
+		
+		/**
+		 * 
+		 * if (activeChar.isVip())
+		 * {
+		 *     Announcements.announceToAll("VIP "+activeChar.getName()+" has been logged in.");
+                *     return;
+		 * }
+		 * 
+		 */
+					
+		L2Clan clan = activeChar.getClan();
+
+	        if (clan != null)
+	        {
+	            if (clan.hasCastle())
+	            {
+	                Castle castle = CastleManager.getInstance().getCastleById(clan.getCastleId());
+	                if ((castle != null) && (activeChar.getObjectId() == clan.getLeaderId()))
+                        {
+	                      Announcements.announceToAll("Lord " + activeChar.getName() + " ruler of " + castle.getName() + " castle is now online!");
+                             return;
+                        }
+	            }
+	        }
+	}
+	
	private static void engage(L2PcInstance cha)
	{
		int _chaid = cha.getObjectId();

 

something like this !

 

This way everytime that enters a check will return (aka will not continue to the next checks of the method)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.