Jump to content
  • 0

[How To]Clan Popping out message


Question

Posted

hey guys i was wondering how is it possible for a clan leader to write a message so it pops up when clan members log in!! this is mainly for freya-hi5 i think.. i would appreciate some help !!

6 answers to this question

Recommended Posts

  • 0
Posted

it's clan notice from community board.you have to compile communityserver(assuming you want this for l2jserver you can find it at their site,there is a guide there).obviously this feature will be under clan tab.

  • 0
Posted

so you want something like...:(example)

a clan leader press .addclanmessage ALL SIEGE AT SATUDRDAY!!!!!!

and when clan members login, this message pops up?

And the clan leader will have the right to add new / clear the messages??

 

If yes, i will work on it in some hours.

  • 0
Posted

hey guys i was wondering how is it possible for a clan leader to write a message so it pops up when clan members log in!! this is mainly for freya-hi5 i think.. i would appreciate some help !!

with client you use with project you use ?

 

also if you got epilogue + it works it is on your community board if you use interlude i advice you to search on l2jserver forums theres a patch there

  • 0
Posted

for last revision l2jserver trunk

Clan message w/o community board

core

Index: java/com/l2jserver/gameserver/model/L2Clan.java
===================================================================
--- java/com/l2jserver/gameserver/model/L2Clan.java	(revision 4874)
+++ java/com/l2jserver/gameserver/model/L2Clan.java	(working copy)
@@ -51,6 +51,7 @@
import com.l2jserver.gameserver.network.serverpackets.ExSubPledgeSkillAdd;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.PledgeReceiveSubPledgeCreated;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowInfoUpdate;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListAll;
@@ -174,6 +175,8 @@
	private boolean _noticeEnabled = false;
	private static final int MAX_NOTICE_LENGTH = 8192;

+	private String _clanMessage; // Non community board message
+	
	/**
	 * Called if a clan is referenced only by id.
	 * In this case all other data needs to be fetched from db
@@ -772,7 +775,7 @@
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("UPDATE clan_data SET leader_id=?,ally_id=?,ally_name=?,reputation_score=?,ally_penalty_expiry_time=?,ally_penalty_type=?,char_penalty_expiry_time=?,dissolving_expiry_time=? WHERE clan_id=?");
+			statement = con.prepareStatement("UPDATE clan_data SET leader_id=?,ally_id=?,ally_name=?,reputation_score=?,ally_penalty_expiry_time=?,ally_penalty_type=?,char_penalty_expiry_time=?,dissolving_expiry_time=?, clan_message=? WHERE clan_id=?");
			statement.setInt(1, getLeaderId());
			statement.setInt(2, getAllyId());
			statement.setString(3, getAllyName());
@@ -781,7 +784,8 @@
			statement.setInt(6, getAllyPenaltyType());
			statement.setLong(7, getCharPenaltyExpiryTime());
			statement.setLong(8, getDissolvingExpiryTime());
-			statement.setInt(9, getClanId());
+			statement.setString(9, getClanMessage());
+			statement.setInt(10, getClanId());
			statement.execute();
			if (Config.DEBUG)
				_log.fine("New clan leader saved in db: " + getClanId());
@@ -900,7 +904,7 @@
			L2ClanMember member;

			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT clan_name,clan_level,hasCastle,ally_id,ally_name,leader_id,crest_id,crest_large_id,ally_crest_id,reputation_score,auction_bid_at,ally_penalty_expiry_time,ally_penalty_type,char_penalty_expiry_time,dissolving_expiry_time FROM clan_data where clan_id=?");
+			PreparedStatement statement = con.prepareStatement("SELECT clan_name,clan_level,hasCastle,ally_id,ally_name,leader_id,crest_id,crest_large_id,ally_crest_id,reputation_score,auction_bid_at,ally_penalty_expiry_time,ally_penalty_type,char_penalty_expiry_time,dissolving_expiry_time,clan_message FROM clan_data where clan_id=?");
			statement.setInt(1, getClanId());
			ResultSet clanData = statement.executeQuery();

@@ -930,6 +934,8 @@
				setReputationScore(clanData.getInt("reputation_score"), false);
				setAuctionBiddedAt(clanData.getInt("auction_bid_at"), false);

+				setMessage(clanData.getString("clan_message"));
+				
				int leaderId = (clanData.getInt("leader_id"));

				PreparedStatement statement2 = con.prepareStatement("SELECT char_name,level,classid,charId,title,power_grade,subpledge,apprentice,sponsor,sex,race FROM characters WHERE clanid=?");
@@ -2835,4 +2841,45 @@
			}
		}
	}
+	
+	public String getClanMessage()
+	{
+		return _clanMessage;
+	}
+	
+	public void setMessage(final String message)
+	{
+		_clanMessage = message;
+	}
+	
+	public void sendEditWindow(final L2PcInstance leader)
+	{
+		try
+		{
+			NpcHtmlMessage msg = new NpcHtmlMessage(5);
+			msg.setFile(null, "data/html/changeclanmsg.htm");
+			msg.replace("%defaultText%", getClanMessage() != null && !getClanMessage().isEmpty()?
+					getClanMessage() : "");
+			leader.sendPacket(msg);
+		} 
+		catch(NullPointerException npe)
+		{
+			_log.warning("L2Clan: Could not find the edit clan message html! : data/html/changeclanmsg.htm");
+		}
+	}
+	
+	public void sendClanMessage(final L2PcInstance member)
+	{
+		try
+		{
+			NpcHtmlMessage msg = new NpcHtmlMessage(5);
+			msg.setFile(null, "data/html/clanmessage.htm");
+			msg.replace("%message%", getClanMessage());
+			member.sendPacket(msg);
+		}
+		catch(NullPointerException npe)
+		{
+			_log.warning("L2Clan: Could not find the clan message html!: data/html/clanmessage.htm");
+		}
+	}
}
Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java	(revision 4874)
+++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -195,6 +195,10 @@
		{
			activeChar.sendPacket(new PledgeSkillList(activeChar.getClan()));

+			final String clanMessage = activeChar.getClan().getClanMessage();
+			if(clanMessage != null && !clanMessage.isEmpty())
+				activeChar.getClan().sendClanMessage(activeChar);
+			
			notifyClanMembers(activeChar);

			notifySponsorOrApprentice(activeChar);
Index: java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java	(revision 4874)
+++ java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java	(working copy)
@@ -27,6 +27,7 @@
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.L2CharPosition;
+import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Npc;
@@ -241,6 +242,33 @@
					Hero.getInstance().showHeroDiary(player, heroclass, heroid, heropage);
				}
			}
+			else if(_command.startsWith("editClanNotice"))
+			{
+				if(!activeChar.isClanLeader())
+				{
+					activeChar.sendMessage("You must be a clan leader to change such text!");
+					return;
+				}
+				String msg = _command.substring(15);
+				if(msg.length() > 100)
+				{
+					activeChar.sendMessage("The text cannot be over 100 characters lenght");
+					activeChar.getClan().sendEditWindow(activeChar);
+					return;
+				}
+				final L2Clan clan = activeChar.getClan();
+				clan.setMessage(msg);
+				if(msg != null && !msg.isEmpty()) // Update notice for online members
+				{
+					for(L2PcInstance mem : clan.getOnlineMembers(0))
+					{
+						if(mem != null)
+							clan.sendClanMessage(mem);
+					}
+				}
+			}
			else
			{
				final IBypassHandler handler = BypassHandler.getInstance().getBypassHandler(_command);

DP

Index: data/html/changeclanmsg.htm
===================================================================
--- data/html/changeclanmsg.htm	(revision 0)
+++ data/html/changeclanmsg.htm	(revision 0)
@@ -0,0 +1,23 @@
+<html>
+<title>Clan Message Editor</title>
+<body>
+Here you will be able to edit your clan's MOTD. Enter the text in the <font color=LEVEL>above box</font> and press <font color=LEVEL>"Set Text"</font>
+<br>
+<center>
+Current Message
+<br>
+<font color="2E9AFE">
+%defaultText%
+</font>
+<br><br>
+<center>
+<font color="FF0000">NOTE: If you enter an empty text, no page will pop up for clan members.</font>
+<br>
+MAX: 100 characters
+<br>
+<MultiEdit var="textbox" width=240 height=100>
+<br>
+<a action="bypass -h editClanNotice $textbox">Set Text</a>
+</center>
+</body>
+</html>
\ No newline at end of file
Index: data/html/clanmessage.htm
===================================================================
--- data/html/clanmessage.htm	(revision 0)
+++ data/html/clanmessage.htm	(revision 0)
@@ -0,0 +1,8 @@
+<html>
+<title>Clan Message</title>
+<center>
+Here is the message of your clan:
+<br>
+%message%
+</body>
+</html>
\ No newline at end of file
Index: data/scripts/handlers/voicedcommandhandlers/ClanMessage.java
===================================================================
--- data/scripts/handlers/voicedcommandhandlers/ClanMessage.java	(revision 0)
+++ data/scripts/handlers/voicedcommandhandlers/ClanMessage.java	(revision 0)
@@ -0,0 +1,31 @@
+/**
+ * 
+ */
+package handlers.voicedcommandhandlers;
+
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author BiggBoss
+ */
+public final class ClanMessage implements IVoicedCommandHandler
+{
+	private final String[] CMD = {"editClanMessage"};
+	
+	@Override
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
+	{
+		if(!activeChar.isClanLeader())
+			return false;
+		
+		activeChar.getClan().sendEditWindow(activeChar);
+		return true;
+	}
+
+	@Override
+	public String[] getVoicedCommandList()
+	{
+		return CMD;
+	}	
+}
Index: data/scripts/handlers/MasterHandler.java
===================================================================
--- data/scripts/handlers/MasterHandler.java	(revision 8319)
+++ data/scripts/handlers/MasterHandler.java	(working copy)
@@ -243,6 +243,7 @@
import handlers.usercommandhandlers.Time;
import handlers.voicedcommandhandlers.Banking;
import handlers.voicedcommandhandlers.ChatAdmin;
+import handlers.voicedcommandhandlers.ClanMessage;
import handlers.voicedcommandhandlers.Debug;
import handlers.voicedcommandhandlers.Lang;
import handlers.voicedcommandhandlers.TvTVoicedInfo;
@@ -552,6 +553,7 @@
			VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Lang());
		if (Config.L2JMOD_DEBUG_VOICE_COMMAND)
			VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Debug());
+		VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new ClanMessage());
		_log.config("Loaded " + VoicedCommandHandler.getInstance().size() + " VoicedHandlers");
	}

Index: dist/sql/server/clan_data.sql
===================================================================
--- dist/sql/server/clan_data.sql	(revision 8319)
+++ dist/sql/server/clan_data.sql	(working copy)
@@ -15,6 +15,7 @@
   `ally_penalty_type` DECIMAL( 1 ) NOT NULL DEFAULT 0,
   `char_penalty_expiry_time` bigint(13) unsigned NOT NULL DEFAULT '0',
   `dissolving_expiry_time` bigint(13) unsigned NOT NULL DEFAULT '0',
+  `clan_message` varchar(100), -- 100 = text lenght
   PRIMARY KEY (`clan_id`),
   KEY `leader_id` (`leader_id`),
   KEY `ally_id` (`ally_id`)

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
Answer this question...

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