[Bobbot-cvs] Plugins/Sphere/PunishSystem JailEntry.cs,1.1,1.2 JailSystem.cs,1.4,1.5
Status: Alpha
Brought to you by:
iainmckay
From: Mr S. C. <mrs...@us...> - 2005-10-18 20:24:45
|
Update of /cvsroot/bobbot/Plugins/Sphere/PunishSystem In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20607/Sphere/PunishSystem Modified Files: JailEntry.cs JailSystem.cs Log Message: -I changed stuff apparently :D Index: JailEntry.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/PunishSystem/JailEntry.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JailEntry.cs 21 Jan 2005 03:29:53 -0000 1.1 --- JailEntry.cs 18 Oct 2005 20:24:33 -0000 1.2 *************** *** 25,32 **** using System.Timers; ! namespace Bot.Plugins.Sphere.PunishSystem ! { ! public class JailEntry ! { #region Private members --- 25,30 ---- using System.Timers; ! namespace Bot.Plugins.Sphere.PunishSystem { ! public class JailEntry { #region Private members *************** *** 45,88 **** #region Public properties ! public virtual string Account ! { get { return m_Account; } set { m_Account = value; } } ! public virtual string Character ! { get { return m_Character; } set { m_Character = value; } } ! public virtual string JailedBy ! { get { return m_GMName; } set { m_GMName = value; } } ! public virtual string Reason ! { get { return m_Reason; } set { m_Reason = value; } } ! public virtual DateTime JailedOn ! { get { return m_JailStart; } set { m_JailStart = value; } } ! public virtual DateTime JailedUntil ! { get { return m_JailEnd; } set { m_JailEnd = value; } } ! public virtual string TimeLeft ! { ! get ! { if (m_JailTimer == null || !m_JailTimer.Enabled) return "Sentence Disabled"; --- 43,78 ---- #region Public properties ! public virtual string Account { get { return m_Account; } set { m_Account = value; } } ! public virtual string Character { get { return m_Character; } set { m_Character = value; } } ! public virtual string JailedBy { get { return m_GMName; } set { m_GMName = value; } } ! public virtual string Reason { get { return m_Reason; } set { m_Reason = value; } } ! public virtual DateTime JailedOn { get { return m_JailStart; } set { m_JailStart = value; } } ! public virtual DateTime JailedUntil { get { return m_JailEnd; } set { m_JailEnd = value; } } ! public virtual string TimeLeft { ! get { if (m_JailTimer == null || !m_JailTimer.Enabled) return "Sentence Disabled"; *************** *** 98,105 **** #region Public methods ! public void StartSentence() ! { ! if (m_JailTimer != null) ! { m_JailTimer.Stop(); m_JailTimer.Dispose(); --- 88,93 ---- #region Public methods ! public void StartSentence() { ! if (m_JailTimer != null) { m_JailTimer.Stop(); m_JailTimer.Dispose(); *************** *** 118,123 **** } ! public bool Load(XmlElement xmlElement) ! { string account = xmlElement.GetAttribute("account"); string jailedon = xmlElement.GetAttribute("jailedon"); --- 106,110 ---- } ! public bool Load(XmlElement xmlElement) { string account = xmlElement.GetAttribute("account"); string jailedon = xmlElement.GetAttribute("jailedon"); *************** *** 139,144 **** } ! public bool Save(XmlElement xmlElement) ! { xmlElement.SetAttribute("account", m_Account); xmlElement.SetAttribute("jailedon", m_JailStart.ToFileTime().ToString()); --- 126,130 ---- } ! public bool Save(XmlElement xmlElement) { xmlElement.SetAttribute("account", m_Account); xmlElement.SetAttribute("jailedon", m_JailStart.ToFileTime().ToString()); *************** *** 177,186 **** #region Event Handlers ! private void OnSentenceServed(object sender, ElapsedEventArgs e) ! { ! try ! { ! if (!m_JailSystem.Release(this)) ! { Bot.Core.Log.WriteLine("Sphere (JailDB)", "Failed to release '{0}'. Retrying in 5 minutes.", m_Account); m_JailTimer.AutoReset = false; --- 163,169 ---- #region Event Handlers ! private void OnSentenceServed(object sender, ElapsedEventArgs e) { ! try { ! if (!m_JailSystem.Release(this)) { Bot.Core.Log.WriteLine("Sphere (JailDB)", "Failed to release '{0}'. Retrying in 5 minutes.", m_Account); m_JailTimer.AutoReset = false; *************** *** 189,198 **** return; } return; } ! catch (System.Exception ex) ! { Bot.Core.Log.WriteLine("Sphere (JailDB)", "Account '{0}' isn't released due to an error! - {1}", m_Account, ex.ToString()); m_JailTimer.AutoReset = false; --- 172,182 ---- return; } + else + this.m_JailSystem.RemoveEntry( this ); return; } ! catch (System.Exception ex) { Bot.Core.Log.WriteLine("Sphere (JailDB)", "Account '{0}' isn't released due to an error! - {1}", m_Account, ex.ToString()); m_JailTimer.AutoReset = false; *************** *** 207,212 **** #region Constructor ! public JailEntry(JailSystem system) ! { m_JailSystem = system; } --- 191,195 ---- #region Constructor ! public JailEntry(JailSystem system) { m_JailSystem = system; } Index: JailSystem.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/PunishSystem/JailSystem.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JailSystem.cs 17 Jul 2005 21:46:28 -0000 1.4 --- JailSystem.cs 18 Oct 2005 20:24:33 -0000 1.5 *************** *** 37,61 **** using UltimaOnline.Sphere.Connection.Messages; ! namespace Bot.Plugins.Sphere.PunishSystem ! { ! public class JailSystem ! { #region Private Members private string JailDatabase = "JailDatabase.xml"; private SphereConnection m_Server; private SpherePlugin m_Parent; ! private JailEntry[] m_JailEntries ! { get { return (JailEntry[]) m_JailEntryList.ToArray(typeof(JailEntry)); } } private ArrayList m_JailEntryList; #endregion #region Public Properties ! public int JailedAccounts ! { get { return m_JailEntryList.Count; } } --- 37,61 ---- using UltimaOnline.Sphere.Connection.Messages; ! namespace Bot.Plugins.Sphere.PunishSystem { ! ! public class JailSystem { ! #region Private Members + private string JailDatabase = "JailDatabase.xml"; private SphereConnection m_Server; private SpherePlugin m_Parent; ! private JailEntry[] m_JailEntries { get { return (JailEntry[]) m_JailEntryList.ToArray(typeof(JailEntry)); } } private ArrayList m_JailEntryList; + #endregion #region Public Properties ! public int JailedAccounts { get { return m_JailEntryList.Count; } } *************** *** 64,69 **** #region Constructor ! public JailSystem(SpherePlugin parent) ! { m_Parent = parent; m_Server = m_Parent.InnerConnection; --- 64,69 ---- #region Constructor ! ! public JailSystem(SpherePlugin parent) { m_Parent = parent; m_Server = m_Parent.InnerConnection; *************** *** 71,76 **** } ! public JailSystem(SpherePlugin parent, string database) ! { m_Parent = parent; m_Server = m_Parent.InnerConnection; --- 71,75 ---- } ! public JailSystem(SpherePlugin parent, string database) { m_Parent = parent; m_Server = m_Parent.InnerConnection; *************** *** 79,88 **** } ! private void Init() ! { m_JailEntryList = new ArrayList(); ! if (!File.Exists(this.JailDatabase)) ! { Log.WriteLine("Sphere (JailDB)", "Database Not Found. Creating '{0}'", this.JailDatabase); StreamWriter newDb = File.CreateText(JailDatabase); --- 78,85 ---- } ! private void Init() { m_JailEntryList = new ArrayList(); ! if (!File.Exists(this.JailDatabase)) { Log.WriteLine("Sphere (JailDB)", "Database Not Found. Creating '{0}'", this.JailDatabase); StreamWriter newDb = File.CreateText(JailDatabase); *************** *** 93,100 **** } ! if (!LoadDatabase()) ! Log.WriteLine("Sphere (JailDB)", "Error occured whilst loading the Jail Database."); ! Log.WriteLine("Sphere (JailDB)", "{0} Jail Entries Loaded", this.m_JailEntries.Length); SaveDatabase(); --- 90,98 ---- } ! if (!LoadDatabase()) { ! Log.WriteLine("Sphere (JailSystem)", "Error occured whilst loading the Jail Database."); ! } ! Log.WriteLine("Sphere (JailSystem)", "{0} Jail Entries Loaded", this.m_JailEntries.Length); SaveDatabase(); *************** *** 102,112 **** m_Server.CustomEvent += new EventHandler(OnCustomEvent); } #endregion #region Database Save/Load ! public bool LoadDatabase() ! { ! try ! { Log.WriteLine("Sphere (JailDB)", "Loading Jail Database from '{0}'...", this.JailDatabase); --- 100,110 ---- m_Server.CustomEvent += new EventHandler(OnCustomEvent); } + #endregion #region Database Save/Load ! ! public bool LoadDatabase() { ! try { Log.WriteLine("Sphere (JailDB)", "Loading Jail Database from '{0}'...", this.JailDatabase); *************** *** 120,125 **** return true; ! foreach(XmlElement xmlElement in xmlList) ! { JailEntry entry = new JailEntry( this ); --- 118,122 ---- return true; ! foreach(XmlElement xmlElement in xmlList) { JailEntry entry = new JailEntry( this ); *************** *** 131,136 **** } ! catch(Exception ex) ! { Log.WriteLine("Sphere (JailDB)", "Failed to load Jail Database file, reason: {0}", ex.ToString()); return false; --- 128,132 ---- } ! catch(Exception ex) { Log.WriteLine("Sphere (JailDB)", "Failed to load Jail Database file, reason: {0}", ex.ToString()); return false; *************** *** 138,145 **** } ! public bool SaveDatabase() ! { ! try ! { Log.WriteLine("Sphere (JailDB)", "Writing database to '{0}'...", this.JailDatabase); --- 134,139 ---- } ! public bool SaveDatabase() { ! try { Log.WriteLine("Sphere (JailDB)", "Writing database to '{0}'...", this.JailDatabase); *************** *** 154,159 **** ! foreach(JailEntry entry in m_JailEntries) ! { XmlElement xmlElement = xmlDoc.CreateElement("JailEntry"); xmlRoot.AppendChild(xmlElement); --- 148,152 ---- ! foreach(JailEntry entry in m_JailEntries) { XmlElement xmlElement = xmlDoc.CreateElement("JailEntry"); xmlRoot.AppendChild(xmlElement); *************** *** 169,397 **** } ! catch(Exception ex) ! { Log.WriteLine("Sphere (JailDB)", "Failed to write Jail Database file, reason: {0}", ex.Message); return false; } } #endregion #region Public Methods - public bool AddEntry(string account, string character, string gm, TimeSpan length, string reason) - { - try - { - if (IsJailed(account)) - return false; ! JailEntry entry = new JailEntry( this ); ! entry.Account = account; ! entry.Character = character; ! entry.JailedBy = gm; ! entry.JailedOn = DateTime.Now; ! entry.JailedUntil = DateTime.Now.Add(length); ! entry.Reason = reason; ! entry.StartSentence(); ! m_JailEntryList.Add(entry); ! return true; ! } ! ! catch { return false; } ! } ! ! public bool DelEntry(string account) ! { ! try ! { ! if (!IsJailed(account)) ! return false; ! ! for (int i = 0; i < m_JailEntryList.Count; i++) ! { ! if (((JailEntry) m_JailEntryList[i]).Account.ToLower() == account.ToLower()) ! { ! m_JailEntryList.RemoveAt(i); ! return true; ! } ! } return false; } ! catch { return false; } } ! public bool EditEntry(string account, string gm, TimeSpan length, string reason) ! { ! try ! { ! if (!IsJailed(account)) ! return false; ! ! JailEntry entry = GetJailEntry(account); ! if (entry.JailedBy.IndexOf(" (Amended by ") > -1) ! entry.JailedBy = entry.JailedBy.Substring(0, entry.JailedBy.IndexOf(' ')); ! if (gm != entry.JailedBy) ! entry.JailedBy += " (Amended by " + gm + ")"; ! if (length.TotalMilliseconds > DateTime.Now.Subtract(entry.JailedUntil).TotalMilliseconds) ! entry.JailedUntil = entry.JailedUntil.Add(length); ! if (reason != null) ! entry.Reason = reason; ! entry.StartSentence(); ! if (!DelEntry(account)) ! return false; ! m_JailEntryList.Add(entry); ! return true; } ! catch { return false; } ! } ! public JailEntry[] GetJailEntryList() ! { ! return m_JailEntries; } ! public JailEntry GetJailEntry(string account) ! { ! foreach (JailEntry i in m_JailEntries) ! { ! if (i.Account.ToLower() == account.ToLower()) ! return i; ! ! } ! return null; ! } ! public bool Jail(string[] args) ! { ! if (args.Length < 5) return false; ! return Jail(args[0], args[1], args[2], args[3], args[4]); } ! public bool Jail(string account, string character, string gm, string length, string reason) ! { if (!m_Server.IsConnected) { return false; } ! try ! { ! if (reason == null || reason == "") ! reason = "None Set"; ! ! if (character == null || character == "") ! character = "All"; ! ! m_Server.WriteLine("account {0} jail 1", account); ! ! Account jailed = AccountRegistration.Instance.GetAccount(account); ! if (jailed == null) ! { ! Log.WriteLine("Sphere (JailDB)", "Account '{0}' doesn't exist and cannot be jailed!", account); ! return false; ! } ! for (int i = 0; i < jailed.Chars; i++) ! { ! m_Server.WriteLine("account {0} char.{1}.send_to_jail={2}", account, i, length); ! } ! if (!AddEntry(account, character, gm, TimeSpan.FromHours(double.Parse(length)), reason)) ! return false; ! Log.WriteLine("Sphere (JailDB)", "Account '{0}' is jailed by {1}! ({2} hours) (Reason: {3})", account, gm, length, reason); ! return true; } ! catch (Exception e) ! { ! Console.WriteLine(e.ToString()); ! return false; } - } ! public bool EditJail(string[] args) ! { ! if (args.Length < 5) ! return false; ! return EditJail(args[0], args[1], args[2], args[3]); } ! public bool EditJail(string account, string gm, string length, string reason) ! { ! if (!m_Server.IsConnected) { return false; } ! ! try ! { ! if (!IsJailed(account)) ! return false; ! ! if (reason == null || reason == "") ! reason = null; ! ! if (!EditEntry(account, gm, TimeSpan.FromHours(double.Parse(length)), reason)) ! return false; ! ! Log.WriteLine("Sphere (JailDB)", "Account Entry '{0}' is edited by {1}! ({2} hours) (Reason: {3})", account, gm, (double.Parse(length) != 0? length : "Unedited"), (reason == null || reason == ""? "Unedited" : reason )); ! return true; ! } ! catch { return false; } ! } ! public bool Release(string[] args) ! { return Release(args[0], args[1]); } ! public bool Release(JailEntry entry) ! { return Release(entry.Account, entry.JailedBy); } ! public bool Release(string account, string gm) ! { if (!m_Server.IsConnected) { return false; } ! try ! { ! if (!IsJailed(account)) ! return false; ! m_Server.WriteLine("account {0} jail 0", account); ! ! Account jailed = AccountRegistration.Instance.GetAccount(account); ! for (int i = 0; i < jailed.Chars; i++) ! { ! m_Server.WriteLine("account {0} char.{1}.release_from_jail", account, i); ! } ! if (!DelEntry(account)) ! return false; ! Log.WriteLine("Sphere (JailDB)", "Account '{0}' is released from jail!", account); ! return true; } ! catch { return false; } } ! public bool IsJailed(string account) ! { ! for (int i = 0; i < m_JailEntryList.Count; i++) ! { ! if (((JailEntry) m_JailEntryList[i]).Account.ToLower() == account.ToLower()) ! return true; } --- 162,328 ---- } ! catch(Exception ex) { Log.WriteLine("Sphere (JailDB)", "Failed to write Jail Database file, reason: {0}", ex.Message); return false; } } + #endregion #region Public Methods ! #region Jail Method ! public bool Jail(string[] args) { ! if (args.Length != 5) { return false; } ! return Jail(args[0], args[1], args[2], args[3], args[4]); } ! public bool Jail(string account, string character, string gm, string length, string reason) { ! if (!m_Server.IsConnected) { return false; } ! if (IsJailed( account )) { ! return EditJail( account , gm , length , reason ); ! } ! if (reason == null || reason == "") { ! reason = "None Set"; ! } ! if (character == null || character == "") { ! character = "All"; ! } ! Account jailed = new Account( account ); ! /*Account jailed = AccountRegistration.Instance.GetAccount( account ); ! if (jailed == null) { ! Log.WriteLine("Sphere (JailSystem)", "Account '{0}' doesn't exist and cannot be jailed!", account); ! return false; ! }*/ ! m_Server.WriteLine("account {0} jail 1", jailed.Name); ! //for (int i = 0; i < jailed.Chars; i++) { ! for (int i = 0; i < 5; i++) { ! m_Server.WriteLine("account {0} char.{1}.send_to_jail={2}", jailed.Name, i, length); } ! JailEntry entry = new JailEntry( this ); ! entry.Account = account; ! entry.Character = character; ! entry.JailedBy = gm; ! entry.JailedOn = DateTime.Now; ! entry.JailedUntil = DateTime.Now.Add(TimeSpan.FromHours(double.Parse(length))); ! entry.Reason = reason; ! entry.StartSentence(); ! AddEntry( entry ); ! Log.WriteLine("Sphere (JailSystem)", "Account '{0}' is jailed by {1}! ({2} hours) (Reason: {3})", account, gm, length, reason); ! return true; } ! #endregion ! #region EditJail Method ! public bool EditJail(string[] args) { ! if (args.Length != 4) { return false; + } ! return EditJail(args[0], args[1], args[2], args[3]); } ! public bool EditJail(string account, string gm, string length, string reason) { if (!m_Server.IsConnected) { return false; } ! JailEntry jailed = GetJailEntry( account ); ! RemoveEntry( jailed ); ! if (reason == null || reason == "") { ! reason = null; ! } ! if (jailed.JailedBy.IndexOf(" (Amended by ") > -1) { ! jailed.JailedBy = jailed.JailedBy.Substring( 0 , jailed.JailedBy.IndexOf( " (Amended by " ) ); ! } ! if (gm.ToLower() != jailed.JailedBy.ToLower()) { ! jailed.JailedBy += " (Amended by " + gm + ")"; ! } ! if (TimeSpan.FromHours(double.Parse(length)).TotalMilliseconds > DateTime.Now.Subtract(jailed.JailedUntil).TotalMilliseconds) { ! jailed.JailedUntil = jailed.JailedUntil.Add( TimeSpan.FromHours(double.Parse(length)) ); } ! if (reason != null) { ! jailed.Reason = reason; } ! jailed.StartSentence(); ! AddEntry( jailed ); ! Log.WriteLine("Sphere (JailSystem)", "Account Entry '{0}' is edited by {1}! ({2} hours) (Reason: {3})", jailed.Account, gm, (double.Parse(length) != 0? length : "Unedited"), (reason == null || reason == ""? "Unedited" : reason )); ! return true; } ! #endregion ! #region Release Method ! public bool Release(string[] args) { return Release(args[0], args[1]); } ! public bool Release(JailEntry entry) { return Release(entry.Account, entry.JailedBy); } ! public bool Release(string account, string gm) { if (!m_Server.IsConnected) { return false; } ! //Account jailed = AccountRegistration.Instance.GetAccount( account ); ! Account jailed = new Account( account ); ! m_Server.WriteLine("account {0} jail 0", jailed.Name); ! //for (int i = 0; i < jailed.Chars; i++) { ! for (int i = 0; i < 5; i++) { ! m_Server.WriteLine("account {0} char.{1}.release_from_jail", jailed.Name, i); ! } ! RemoveEntry( GetJailEntry( jailed.Name ) ); ! Log.WriteLine("Sphere (JailSystem)", "Account '{0}' is released from jail!", jailed.Name); ! return true; ! } ! ! #endregion ! ! #region JailEntry Handling ! ! public void AddEntry(JailEntry entry) { ! if (!m_JailEntryList.Contains( entry )) { ! m_JailEntryList.Add( entry ); } + return; + } ! public void RemoveEntry(JailEntry entry) { ! if (m_JailEntryList.Contains( entry )) { ! this.m_JailEntryList.Remove( entry ); ! } ! return; } ! public bool IsJailed(string account) { ! account = account.ToLower(); + foreach (JailEntry entry in m_JailEntryList) { + if (entry.Account.ToLower() == account) { + return true; + } } *************** *** 399,434 **** } #endregion #region Event handlers ! private void OnCustomEvent(object sender, EventArgs args) ! { ! if(args is PlayerJailedEventArgs) OnPlayerJailed(sender, (PlayerJailedEventArgs) args); ! else if(args is PlayerReleasedEventArgs) OnPlayerReleased(sender, (PlayerReleasedEventArgs) args); } ! private void OnPlayerJailed(object sender, PlayerJailedEventArgs args) ! { ! string account = m_Server.GetItemProperty(args.Message.Player, "account"); ! string character = m_Server.GetItemProperty(args.Message.Player, "name"); ! string gm = m_Server.GetItemProperty(args.Message.GM, "name"); ! if (!Jail(account, character, gm, args.Message.Length, args.Message.Reason)) ! Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to Jail Account '{0}'.", account); } ! private void OnPlayerReleased(object sender, PlayerReleasedEventArgs args) ! { ! string account = m_Server.GetItemProperty(args.Message.Player, "account"); ! string gm = m_Server.GetItemProperty(args.Message.GM, "name"); ! if (!Release(account, gm)) ! Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to Release Account '{0}'.", account); } #endregion } } --- 330,399 ---- } + public JailEntry[] GetJailEntryList() { + return m_JailEntries; + } + + public JailEntry GetJailEntry(string account) { + account = account.ToLower(); + + foreach (JailEntry entry in m_JailEntries) { + if (entry.Account.ToLower() == account) { + return entry; + } + } + + return null; + } + + #endregion + #endregion #region Event handlers ! private void OnCustomEvent(object sender, EventArgs args) { ! if(args is PlayerJailedEventArgs) { OnPlayerJailed(sender, (PlayerJailedEventArgs) args); ! } else if(args is PlayerReleasedEventArgs) { OnPlayerReleased(sender, (PlayerReleasedEventArgs) args); + } else if(args is JSInformationRequestEventArgs) { + OnJSInformationRequest(sender, (JSInformationRequestEventArgs) args); + } } ! private void OnPlayerJailed(object sender, PlayerJailedEventArgs args) { ! if (IsJailed( args.Message.PlayerAccount )) { ! RemoveEntry( GetJailEntry( args.Message.PlayerAccount ) ); ! } ! if (!Jail( args.Message.PlayerAccount, args.Message.PlayerName, args.Message.GM, args.Message.Length, args.Message.Reason)) { ! Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to Jail Account '{0}'.", args.Message.PlayerAccount); ! } ! } ! private void OnPlayerReleased(object sender, PlayerReleasedEventArgs args) { ! if (!Release( args.Message.Player, args.Message.GM )) { ! Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to Release Account '{0}'.", args.Message.Player); ! } } ! private void OnJSInformationRequest(object snder, JSInformationRequestEventArgs args) { ! JailEntry entry = GetJailEntry( args.Message.Account ); if (entry != null) { SendMessage( args.Message.RequestBy, string.Format( "Jailed By: {0}", entry.JailedBy)); SendMessage( args.Message.RequestBy, string.Format( "Jail Date: {0}", entry.JailedOn)); SendMessage( args.Message.RequestBy, string.Format( "Release Date: {0} ({1})", entry.JailedUntil, entry.TimeLeft)); SendMessage( args.Message.RequestBy, string.Format( "Reason: {0}", entry.Reason)); } else { ! SendMessage( args.Message.RequestBy, "There is no stored record of this jailing. It may have been delayed, lost in error, or this account may not be jailed."); } ! return; } #endregion + + public void SendMessage(string uid, string message) { + while (message.Length >= 50) { + SphereConnection.Instance.WriteLine("uid.{0}.f_jail_msg \"{1}\"", uid, message.Substring(0, 50)); + message = message.Remove(0, 50); + } + if (message.Length > 0) { + SphereConnection.Instance.WriteLine("uid.{0}.f_jail_msg {1}", uid, message); + } + SphereConnection.Instance.WriteLine("uid.{0}.f_jail_write", uid); + } } } |