Jump to content

[Share] Announcements System


Dulens.

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;" ?
Link to comment
Share on other sites

### 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)

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...