Jump to content

Recommended Posts

Posted

Γεια σε ολους , ζητηθηκε.

 

Ο clan leader μπορει να γραψει .clanannounce_add για να προσθεσει μια ανακοινωση η οποια θα σταλθει σε ολα τα clan members , αλλα και οσοι ειναι offline θα την δουν μολις μπουν. Π.χ θελει να ανακοινωσει : simera oli 5 i ora siege aden  , αλλα θελει να βεβαιωθει οτι δε θα το ξεχασει κανεις. Επισης και να ηταν Online οταν εγινε η ανακοινωση , παλι οταν ο παιχτης μπει θα του σταλθει.Επισης μπορει να γραψει .clanannounce_remove για να αφαιρεσει την ανακοινωση για να βαλει καινουρια.

 

PS:το αρχειο ExShowScreenMessage θα το εχετε μη το βαλετε, εκτος αν εχετε clean L2J

 

### Eclipse Workspace Patch 1.0
#P Chr.6DTP
Index: sql/characters.sql
===================================================================
--- sql/characters.sql	(revision 8778)
+++ sql/characters.sql	(working copy)
@@ -79,6 +79,7 @@
   clan_join_expiry_time DECIMAL(20,0) NOT NULL DEFAULT 0,
   clan_create_expiry_time DECIMAL(20,0) NOT NULL DEFAULT 0,
   death_penalty_level int(2) NOT NULL DEFAULT 0,
+  announce varchar(100) NOT NULL default ''
   PRIMARY KEY  (obj_Id),
   KEY `clanid` (`clanid`)
) ;

### Eclipse Workspace Patch 1.0
#P Chr.6GMS
Index: java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java	(revision 5263)
+++ java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java	(working copy)
@@ -55,8 +55,10 @@
import net.sf.l2j.gameserver.model.entity.TvTEvent;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.serverpackets.Die;
import net.sf.l2j.gameserver.serverpackets.EtcStatusUpdate;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.serverpackets.ExStorageMaxCount;
import net.sf.l2j.gameserver.serverpackets.FriendList;
import net.sf.l2j.gameserver.serverpackets.HennaInfo;
@@ -71,6 +73,7 @@
import net.sf.l2j.gameserver.serverpackets.SignsSky;
import net.sf.l2j.gameserver.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.serverpackets.UserInfo;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage.SMPOS;
import net.sf.l2j.gameserver.util.FloodProtector;

/**
@@ -251,6 +254,8 @@

         SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
         Announcements.getInstance().showAnnouncements(activeChar);
+        
+        loadAnnounceClan(activeChar);

		Quest.playerEnter(activeChar);
		activeChar.sendPacket(new QuestList());
@@ -350,6 +355,18 @@
         TvTEvent.onLogin(activeChar);
	}

+	private void loadAnnounceClan(L2PcInstance pc){
+		if(pc.hasNewAnnounce()){
+			CreatureSay msg1 = new CreatureSay(1,Say2.CLAN,"Clan Announcement",pc.getAnnounce());
+			
+			ExShowScreenMessage msg2 = new ExShowScreenMessage(pc.getAnnounce(), 15000, SMPOS.TOP_CENTER, true);
+		
+		     pc.sendPacket(msg1);
+		     pc.sendPacket(msg2);
+     		
+		}
+	}
+	
     /**
      * @param activeChar
      */
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 5263)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -214,8 +214,8 @@
	private static final String RESTORE_SKILL_SAVE = "SELECT skill_id,skill_level,effect_count,effect_cur_time, reuse_delay FROM character_skills_save WHERE char_obj_id=? AND class_index=? AND restore_type=? ORDER BY buff_index ASC";
	private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";

-    private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
-    private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
+    private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,announce=? WHERE obj_id=?";
+    private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,announce FROM characters WHERE obj_id=?";
     private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
     private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
     private static final String UPDATE_CHAR_SUBCLASS = "UPDATE character_subclasses SET exp=?,sp=?,level=?,class_id=? WHERE char_obj_id=? AND class_index =?";
@@ -451,6 +451,8 @@

	private boolean _noble = false;
	private boolean _hero = false;
+	
+	private String announce = null;

	/** The L2FolkInstance corresponding to the last Folk wich one the player talked. */
	private L2FolkInstance _lastFolkNpc = null;
@@ -4671,6 +4673,13 @@
	{
		return _partyMatchingMemo;
	}
+	
+	public boolean hasNewAnnounce(){
+		if(getAnnounce() != "" && getAnnounce() != null)
+			return true;
+		
+		return false;
+	}

	public boolean isPartyMatchingShowClass()
	{
@@ -5595,6 +5604,7 @@
				player.setOnlineTime(rset.getLong("onlinetime"));
				player.setNewbie(rset.getInt("newbie")==1);
				player.setNoble(rset.getInt("nobless")==1);
+				player.setAnnounce(rset.getString("announce"));

				player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
				if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
@@ -6059,7 +6069,8 @@
			statement.setLong(54, getClanCreateExpiryTime());
			statement.setString(55, getName());
			statement.setLong(56, getDeathPenaltyBuffLevel());
-            statement.setInt(57, getObjectId());
+			statement.setString(57, getAnnounce());
+            statement.setInt(58, getObjectId());

			statement.execute();
			statement.close();
@@ -8215,6 +8226,15 @@
		return true;
	}

+	public String getAnnounce()
+	{
+		return announce;
+	}
+	
+	public void setAnnounce(String newAnnounce){
+		announce = newAnnounce;
+	}
+	
     public boolean isNoble()
     {
     	return _noble;
Index: java/net/sf/l2j/gameserver/serverpackets/ExShowScreenMessage.java
===================================================================
--- java/net/sf/l2j/gameserver/serverpackets/ExShowScreenMessage.java	(revision 0)
+++ java/net/sf/l2j/gameserver/serverpackets/ExShowScreenMessage.java	(revision 0)
@@ -0,0 +1,125 @@
+/*
+ * 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.serverpackets;
+
+public class ExShowScreenMessage extends L2GameServerPacket
+{
+	public static enum SMPOS
+	{
+		DUMMY, TOP_LEFT, TOP_CENTER, TOP_RIGHT, MIDDLE_LEFT, MIDDLE_CENTER, MIDDLE_RIGHT, BOTTOM_CENTER, BOTTOM_RIGHT,
+	}
+	
+	private final int _type;
+	private final int _sysMessageId;
+	private final int _hide;
+	private final int _unk2;
+	private final int _unk3;
+	private final int _unk4;
+	private final int _size;
+	private final int _position;
+	private final boolean _effect;
+	private final String _text;
+	private final int _time;
+	
+	public ExShowScreenMessage(String text, int time)
+	{
+		_type = 1;
+		_sysMessageId = -1;
+		_hide = 0;
+		_unk2 = 0;
+		_unk3 = 0;
+		_unk4 = 0;
+		_position = 0x02;
+		_text = text;
+		_time = time;
+		_size = 0;
+		_effect = false;
+	}
+	
+	public ExShowScreenMessage(String text, int time, SMPOS pos, boolean effect)
+	{
+		this(text, time, pos.ordinal(), effect);
+	}
+	
+	public ExShowScreenMessage(String text, int time, int pos, boolean effect)
+	{
+		_type = 1;
+		_sysMessageId = -1;
+		_hide = 0;
+		_unk2 = 0;
+		_unk3 = 0;
+		_unk4 = 0;
+		_position = pos;
+		_text = text;
+		_time = time;
+		_size = 0;
+		_effect = effect;
+	}
+	
+	public ExShowScreenMessage(int type, int messageId, int position, int unk1, int size, int unk2, int unk3, boolean showEffect, int time, int unk4, String text)
+	{
+		_type = type;
+		_sysMessageId = messageId;
+		_hide = unk1;
+		_unk2 = unk2;
+		_unk3 = unk3;
+		_unk4 = unk4;
+		_position = position;
+		_text = text;
+		_time = time;
+		_size = size;
+		_effect = showEffect;
+	}
+	
+	// Close packet
+	public ExShowScreenMessage()
+	{
+		_type = 1;
+		_sysMessageId = -1;
+		_hide = 1; // hide it
+		_unk2 = 0;
+		_unk3 = 0;
+		_unk4 = 0;
+		_position = 0x02;
+		_text = "";
+		_time = 0;
+		_size = 0;
+		_effect = false;
+	}
+	
+	@Override
+	public String getType()
+	{
+		return "[s]FE:39 ExShowScreenMessage";
+	}
+	
+	@Override
+	protected void writeImpl()
+	{
+		writeC(0xfe);
+		writeH(0x38);
+		writeD(_type); // 0 - system messages, 1 - your defined text
+		writeD(_sysMessageId); // system message id (_type must be 0 otherwise no effect)
+		writeD(_position); // message position
+		writeD(_hide); // hide
+		writeD(_size); // font size 0 - normal, 1 - small
+		writeD(_unk2); // ?
+		writeD(_unk3); // ?
+		writeD(_effect == true ? 1 : 0); // upper effect (0 - disabled, 1 enabled) - _position must be 2 (center) otherwise no effect
+		writeD(_time); // time
+		writeD(_unk4); // ?
+		writeS(_text); // your text (_type must be 1, otherwise no effect)
+	}
+}
Index: java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java	(revision 5263)
+++ java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java	(working copy)
@@ -18,22 +18,29 @@
  */
package net.sf.l2j.gameserver.clientpackets;

+import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.util.logging.Level;
import java.util.logging.Logger;

import net.sf.l2j.Config;
+import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.communitybbs.CommunityBoard;
import net.sf.l2j.gameserver.handler.AdminCommandHandler;
import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
import net.sf.l2j.gameserver.model.L2CharPosition;
+import net.sf.l2j.gameserver.model.L2ClanMember;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.entity.L2Event;
import net.sf.l2j.gameserver.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.serverpackets.CreatureSay;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage.SMPOS;

/**
  * This class ...
@@ -85,6 +92,60 @@
			{
				comeHere(activeChar);
			}
+			else if (_command.startsWith("clan_ann")){
+				String announce = _command.substring(9);
+				
+				if(announce == null || announce == ""){
+					activeChar.sendMessage("nothing happened");
+					return;
+				}
+				
+				else if(announce.length() >= 100){
+					activeChar.sendMessage("Max Length: 100");
+					return;
+				}
+				
+				else if(activeChar.hasNewAnnounce()){
+					activeChar.sendMessage("There is already a clan announcement, delete it first.");
+					return;
+				}
+				
+				else {
+					CreatureSay msg1 = new CreatureSay(1,Say2.CLAN,"Clan Announcement",announce);
+					ExShowScreenMessage msg2 = new ExShowScreenMessage(announce, 15000, SMPOS.TOP_CENTER, true);
+					for(L2ClanMember member : activeChar.getClan().getMembers()){
+						L2PcInstance real = member.getPlayerInstance();
+						if(real == null)
+							continue;
+						if(real.isOnline() == 1){
+						real.setAnnounce(announce);
+						real.sendPacket(msg1);
+						real.sendPacket(msg2);
+						}
+					}
+					
+					Connection con = null;
+					PreparedStatement state = null;
+					
+					try{
+						con = L2DatabaseFactory.getInstance().getConnection();
+						state = con.prepareStatement("UPDATE characters SET announce=? WHERE clanid=?");
+						state.setString(1, announce);
+						state.setInt(2, activeChar.getClan().getClanId());
+						state.execute();
+						
+						state.close();
+					}
+					
+					catch(Exception ie){
+						ie.printStackTrace();
+					}
+					finally{
+						con.close();
+					}
+					
+				}
+			}
			else if (_command.startsWith("player_help "))
			{
				playerHelp(activeChar, _command.substring(12));
Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/clanannounce.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/clanannounce.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/clanannounce.java	(revision 0)
@@ -0,0 +1,108 @@
+
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import javolution.text.TextBuilder;
+import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.L2ClanMember;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage;
+import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
+
+/**
+ *
+ * @author  irat
+ */
+public class clanannounce implements IVoicedCommandHandler
+{
+
+	ExShowScreenMessage screenMessage = new ExShowScreenMessage("Using clan notice system services.",2);
+	private final String[] commands = {"clanannounce_add","clanannounce_remove"};
+	
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+	{
+		if(activeChar == null)
+			return false;
+		
+		if(!activeChar.isClanLeader())
+		   return false;
+		   
+		else if(activeChar.getClan() == null )
+			  return false;
+		
+		else if(activeChar.getClan().getMembersCount() == 0){
+			activeChar.sendMessage("You don't have any members");
+			return false;
+		}
+		
+		if(command.equals("clanannounce_add")){
+			activeChar.sendPacket(screenMessage);
+			showChat(activeChar);	
+		}
+		else if(command.equals("clanannounce_remove")){
+			for(L2ClanMember member : activeChar.getClan().getMembers()){
+				L2PcInstance real = member.getPlayerInstance();
+				
+				
+				if(real == null)
+					continue;
+				
+				if(real.isOnline() == 1){
+					real.setAnnounce("");
+				}
+			}
+			Connection con = null;
+			PreparedStatement state = null;
+			
+			try{
+				con = L2DatabaseFactory.getInstance().getConnection();
+				state = con.prepareStatement("UPDATE characters SET announce=? WHERE clanid=?");
+				state.setString(1,"");
+				state.setInt(2,activeChar.getClan().getClanId());
+				
+				state.execute();
+				state.close();
+			}
+			catch(Exception ie){
+				ie.printStackTrace();
+			}
+			finally{
+				try
+				{
+					con.close();
+				}
+				catch (SQLException e2)
+				{
+					//
+				}
+			}
+		}
+		return true;
+	}
+	
+	private void showChat(L2PcInstance playable){
+		NpcHtmlMessage html = new NpcHtmlMessage(1);
+		TextBuilder tb = new TextBuilder();
+		
+		tb.append("<html><head>");
+		tb.append("<title>Clan Notice</title></head><body>");
+		tb.append("<center><font color=\"FFFF00\">Hey! Welcome </font>"+"<font color=\"FF11FF\">"+playable.getName()+"</font></center>");
+		tb.append("<font color=\"FFAA23\">Here you can handle the clan notice system.<br>Create a new announce to broadcast in all your clan members.<br>Offline members will be informed when they log in.</font>");
+		tb.append("<br><br><center><font color=\"55FF55\">Creating New Announce:</font><br>");
+		tb.append("<multiedit var=\"clan_announce\" width=240 height=30>");
+	    tb.append("<br><button value=\"Broadcast Announce\" action=\"bypass -h clan_ann $clan_announce\" width=60 height=15 length=\"3000\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br>");
+		tb.append("</center></body></html>");
+		html.setHtml(tb.toString());
+		playable.sendPacket(html);
+	}
+
+	public String[] getVoicedCommandList()
+	{
+		return commands;
+	}
+	
+}

Guest Elfocrash
Posted

Nice idea.No more macro spams.Gj

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