Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
786
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/Data.cs
Normal file
786
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/Data.cs
Normal file
@@ -0,0 +1,786 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Accounting;
|
||||
|
||||
namespace Knives.Chat3
|
||||
{
|
||||
public enum OnlineStatus { Online, Away, Busy, Hidden }
|
||||
|
||||
public class Data
|
||||
{
|
||||
public static void Save()
|
||||
{
|
||||
foreach (Mobile m in new ArrayList(s_Datas.Keys))
|
||||
if (m.Deleted)
|
||||
s_Datas.Remove(m);
|
||||
|
||||
if (!Directory.Exists("Saves/Chat/"))
|
||||
Directory.CreateDirectory("Saves/Chat/");
|
||||
|
||||
GenericWriter writer = new BinaryFileWriter(Path.Combine("Saves/Chat/", "Chat34.bin"), true);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(s_Filters.Count);
|
||||
foreach (string str in s_Filters)
|
||||
writer.Write(str);
|
||||
|
||||
writer.Write((int)s_FilterPenalty);
|
||||
writer.Write(s_MaxMsgs);
|
||||
writer.Write(s_ChatSpam);
|
||||
writer.Write(s_MsgSpam);
|
||||
writer.Write(s_RequestSpam);
|
||||
writer.Write(s_FilterBanLength);
|
||||
writer.Write(s_IrcPort);
|
||||
writer.Write(s_IrcMaxAttempts);
|
||||
writer.Write(s_ShowStaff);
|
||||
writer.Write(s_IrcEnabled);
|
||||
writer.Write(s_IrcAutoConnect);
|
||||
writer.Write(s_IrcAutoReconnect);
|
||||
writer.Write(s_FilterSpeech);
|
||||
writer.Write(s_FilterMsg);
|
||||
writer.Write((int)s_IrcStaffColor);
|
||||
writer.Write(s_IrcServer);
|
||||
writer.Write(s_IrcRoom);
|
||||
writer.Write(s_IrcNick);
|
||||
|
||||
foreach (Data data in new ArrayList(s_Datas.Values))
|
||||
if (data.Mobile.Player && ((Account)data.Mobile.Account).LastLogin < DateTime.Now - TimeSpan.FromDays(30))
|
||||
s_Datas.Remove(data.Mobile);
|
||||
|
||||
writer.Write(s_Datas.Count);
|
||||
foreach (Data data in s_Datas.Values)
|
||||
data.Save(writer);
|
||||
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
if ( !File.Exists( Path.Combine( "Saves/Chat/", "Chat34.bin" ) ) )
|
||||
return;
|
||||
|
||||
using (FileStream bin = new FileStream(Path.Combine("Saves/Chat/", "Chat34.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
GenericReader reader = new BinaryFileReader(new BinaryReader(bin));
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
int count = reader.ReadInt();
|
||||
for(int i = 0; i < count; ++i )
|
||||
s_Filters.Add(reader.ReadString());
|
||||
|
||||
s_FilterPenalty = (FilterPenalty)reader.ReadInt();
|
||||
s_MaxMsgs = reader.ReadInt();
|
||||
s_ChatSpam = reader.ReadInt();
|
||||
s_MsgSpam = reader.ReadInt();
|
||||
s_RequestSpam = reader.ReadInt();
|
||||
s_FilterBanLength = reader.ReadInt();
|
||||
s_IrcPort = reader.ReadInt();
|
||||
s_IrcMaxAttempts = reader.ReadInt();
|
||||
s_ShowStaff = reader.ReadBool();
|
||||
s_IrcEnabled = reader.ReadBool();
|
||||
s_IrcAutoConnect = reader.ReadBool();
|
||||
s_IrcAutoReconnect = reader.ReadBool();
|
||||
s_FilterSpeech = reader.ReadBool();
|
||||
s_FilterMsg = reader.ReadBool();
|
||||
s_IrcStaffColor = (IrcColor)reader.ReadInt();
|
||||
s_IrcServer = reader.ReadString();
|
||||
s_IrcRoom = reader.ReadString();
|
||||
s_IrcNick = reader.ReadString();
|
||||
|
||||
count = reader.ReadInt();
|
||||
Data data;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
data = new Data();
|
||||
data.Load(reader);
|
||||
|
||||
if (data.Mobile != null)
|
||||
s_Datas[data.Mobile] = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Static Definitions
|
||||
|
||||
private static Hashtable s_Datas = new Hashtable();
|
||||
private static ArrayList s_Filters = new ArrayList();
|
||||
private static ArrayList s_IrcList = new ArrayList();
|
||||
private static FilterPenalty s_FilterPenalty;
|
||||
private static int s_MaxMsgs = 50;
|
||||
private static int s_ChatSpam = 2;
|
||||
private static int s_MsgSpam = 5;
|
||||
private static int s_RequestSpam = 24;
|
||||
private static int s_FilterBanLength = 5;
|
||||
private static int s_IrcPort = 6667;
|
||||
private static int s_IrcMaxAttempts = 3;
|
||||
private static bool s_ShowStaff = false;
|
||||
private static bool s_IrcEnabled = false;
|
||||
private static bool s_IrcAutoConnect = false;
|
||||
private static bool s_IrcAutoReconnect = false;
|
||||
private static bool s_FilterSpeech = false;
|
||||
private static bool s_FilterMsg = false;
|
||||
private static IrcColor s_IrcStaffColor = IrcColor.Black;
|
||||
private static string s_IrcServer = "";
|
||||
private static string s_IrcRoom = "";
|
||||
private static string s_IrcNick = Server.Misc.ServerList.ServerName;
|
||||
|
||||
public static Hashtable Datas { get { return s_Datas; } }
|
||||
public static ArrayList Filters { get { return s_Filters; } }
|
||||
public static ArrayList IrcList { get { return s_IrcList; } }
|
||||
public static FilterPenalty FilterPenalty { get { return s_FilterPenalty; } set { s_FilterPenalty = value; } }
|
||||
public static int MaxMsgs { get { return s_MaxMsgs; } set { s_MaxMsgs = value; } }
|
||||
public static int ChatSpam { get { return s_ChatSpam; } set { s_ChatSpam = value; } }
|
||||
public static int MsgSpam { get { return s_MsgSpam; } set { s_MsgSpam = value; } }
|
||||
public static int RequestSpam { get { return s_RequestSpam; } set { s_RequestSpam = value; } }
|
||||
public static int FilterBanLength { get { return s_FilterBanLength; } set { s_FilterBanLength = value; } }
|
||||
public static int IrcPort { get { return s_IrcPort; } set { s_IrcPort = value; } }
|
||||
public static int IrcMaxAttempts { get { return s_IrcMaxAttempts; } set { s_IrcMaxAttempts = value; } }
|
||||
public static bool ShowStaff { get { return s_ShowStaff; } set { s_ShowStaff = value; } }
|
||||
public static bool IrcAutoConnect { get { return s_IrcAutoConnect; } set { s_IrcAutoConnect = value; } }
|
||||
public static bool IrcAutoReconnect { get { return s_IrcAutoReconnect; } set { s_IrcAutoReconnect = value; } }
|
||||
public static bool FilterSpeech { get { return s_FilterSpeech; } set { s_FilterSpeech = value; } }
|
||||
public static bool FilterMsg { get { return s_FilterMsg; } set { s_FilterMsg = value; } }
|
||||
public static string IrcServer { get { return s_IrcServer; } set { s_IrcServer = value; } }
|
||||
public static string IrcNick { get { return s_IrcNick; } set { s_IrcNick = value; } }
|
||||
|
||||
public static bool IrcEnabled
|
||||
{
|
||||
get { return s_IrcEnabled; }
|
||||
set
|
||||
{
|
||||
s_IrcEnabled = value;
|
||||
if (!value)
|
||||
{
|
||||
IrcConnection.Connection.CancelConnect();
|
||||
IrcConnection.Connection.Disconnect(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IrcColor IrcStaffColor
|
||||
{
|
||||
get { return s_IrcStaffColor; }
|
||||
set
|
||||
{
|
||||
if ((int)value > 15)
|
||||
value = (IrcColor)0;
|
||||
|
||||
if ((int)value < 0)
|
||||
value = (IrcColor)15;
|
||||
|
||||
s_IrcStaffColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static Data GetData(Mobile m)
|
||||
{
|
||||
if (s_Datas[m] == null)
|
||||
return new Data(m);
|
||||
|
||||
return (Data)s_Datas[m];
|
||||
}
|
||||
|
||||
public static string IrcRoom
|
||||
{
|
||||
get { return s_IrcRoom; }
|
||||
set
|
||||
{
|
||||
s_IrcRoom = value;
|
||||
|
||||
if (s_IrcRoom.IndexOf("#") != 0)
|
||||
s_IrcRoom = "#" + s_IrcRoom;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Class Definitions
|
||||
|
||||
private Mobile c_Mobile;
|
||||
private Channel c_CurrentChannel;
|
||||
private OnlineStatus c_Status;
|
||||
private object c_Recording;
|
||||
private ArrayList c_Friends, c_Ignores, c_Messages, c_GIgnores, c_GListens, c_Channels, c_IrcIgnores;
|
||||
private Hashtable c_Sounds, c_ChannelColors;
|
||||
private int c_GlobalMC, c_GlobalCC, c_GlobalGC, c_GlobalFC, c_GlobalWC, c_SystemC, c_ChannelPP, c_FriendsPP, c_MailPP, c_DefaultSound, c_StaffC;
|
||||
private bool c_GlobalAccess, c_Global, c_GlobalM, c_GlobalC, c_GlobalG, c_GlobalF, c_GlobalW, c_Banned, c_FriendsOnly, c_MsgSound, c_ByRequest, c_FriendAlert, c_SevenDays, c_ReadReceipt, c_IrcRaw, c_QuickBar;
|
||||
private string c_AwayMsg, c_FriendsSpeech, c_ChannelsSpeech, c_MailSpeech;
|
||||
private DateTime c_BannedUntil;
|
||||
|
||||
public Mobile Mobile { get { return c_Mobile; } }
|
||||
public Channel CurrentChannel { get { return c_CurrentChannel; } set { c_CurrentChannel = value; } }
|
||||
public OnlineStatus Status { get { return c_Status; } set { c_Status = value; } }
|
||||
public object Recording{ get{ return c_Recording; } set{ c_Recording = value; } }
|
||||
public ArrayList Friends { get { return c_Friends; } }
|
||||
public ArrayList Ignores { get { return c_Ignores; } }
|
||||
public ArrayList Messages { get { return c_Messages; } }
|
||||
public ArrayList GIgnores { get { return c_GIgnores; } }
|
||||
public ArrayList GListens { get { return c_GListens; } }
|
||||
public ArrayList Channels { get { return c_Channels; } }
|
||||
public ArrayList IrcIgnores { get { return c_IrcIgnores; } }
|
||||
public Hashtable ChannelColors { get { return c_ChannelColors; } }
|
||||
public bool Global { get { return c_Global; } set { c_Global = value; } }
|
||||
public bool GlobalM { get { return c_GlobalM && c_Global; } set { c_GlobalM = value; } }
|
||||
public bool GlobalC { get { return c_GlobalC && c_Global; } set { c_GlobalC = value; } }
|
||||
public bool GlobalG { get { return c_GlobalG && c_Global; } set { c_GlobalG = value; } }
|
||||
public bool GlobalF { get { return c_GlobalF && c_Global; } set { c_GlobalF = value; } }
|
||||
public bool GlobalW { get { return c_GlobalW && c_Global; } set { c_GlobalW = value; } }
|
||||
public bool FriendsOnly { get { return c_FriendsOnly; } set { c_FriendsOnly = value; } }
|
||||
public bool MsgSound { get { return c_MsgSound; } set { c_MsgSound = value; } }
|
||||
public bool ByRequest { get { return c_ByRequest; } set { c_ByRequest = value; } }
|
||||
public bool FriendAlert { get { return c_FriendAlert; } set { c_FriendAlert = value; } }
|
||||
public bool SevenDays { get { return c_SevenDays; } set { c_SevenDays = value; } }
|
||||
public bool ReadReceipt { get { return c_ReadReceipt; } set { c_ReadReceipt = value; } }
|
||||
public bool IrcRaw { get { return c_IrcRaw; } set { c_IrcRaw = value; } }
|
||||
public bool QuickBar { get { return c_QuickBar; } set { c_QuickBar = value; } }
|
||||
public int GlobalMC { get { return c_GlobalMC; } set { c_GlobalMC = value; } }
|
||||
public int GlobalCC { get { return c_GlobalCC; } set { c_GlobalCC = value; } }
|
||||
public int GlobalGC { get { return c_GlobalGC; } set { c_GlobalGC = value; } }
|
||||
public int GlobalFC { get { return c_GlobalFC; } set { c_GlobalFC = value; } }
|
||||
public int GlobalWC { get { return c_GlobalWC; } set { c_GlobalWC = value; } }
|
||||
public int SystemC { get { return c_SystemC; } set { c_SystemC = value; } }
|
||||
public int StaffC { get { return c_StaffC; } set { c_StaffC = value; } }
|
||||
public string AwayMsg { get { return c_AwayMsg; } set { c_AwayMsg = value; } }
|
||||
public string FriendsSpeech { get { return c_FriendsSpeech; } set { c_FriendsSpeech = value; } }
|
||||
public string ChannelsSpeech { get { return c_ChannelsSpeech; } set { c_ChannelsSpeech = value; } }
|
||||
public string MailSpeech { get { return c_MailSpeech; } set { c_MailSpeech = value; } }
|
||||
|
||||
public int FriendsPP
|
||||
{
|
||||
get { return c_FriendsPP; }
|
||||
set
|
||||
{
|
||||
c_FriendsPP = value;
|
||||
|
||||
if (c_FriendsPP < 5)
|
||||
c_FriendsPP = 5;
|
||||
if (c_FriendsPP > 15)
|
||||
c_FriendsPP = 15;
|
||||
}
|
||||
}
|
||||
|
||||
public int ChannelPP
|
||||
{
|
||||
get { return c_ChannelPP; }
|
||||
set
|
||||
{
|
||||
c_ChannelPP = value;
|
||||
|
||||
if (c_ChannelPP < 5)
|
||||
c_ChannelPP = 5;
|
||||
if (c_ChannelPP > 15)
|
||||
c_ChannelPP = 15;
|
||||
}
|
||||
}
|
||||
|
||||
public int MailPP
|
||||
{
|
||||
get { return c_MailPP; }
|
||||
set
|
||||
{
|
||||
c_MailPP = value;
|
||||
|
||||
if (c_MailPP < 3)
|
||||
c_MailPP = 3;
|
||||
if (c_MailPP > 10)
|
||||
c_MailPP = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public int DefaultSound
|
||||
{
|
||||
get { return c_DefaultSound; }
|
||||
set
|
||||
{
|
||||
foreach (Mobile m in c_Sounds.Keys)
|
||||
if ((int)c_Sounds[m] == c_DefaultSound)
|
||||
c_Sounds[m] = value;
|
||||
|
||||
c_DefaultSound = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool GlobalAccess
|
||||
{
|
||||
get { return c_GlobalAccess || c_Mobile.AccessLevel >= AccessLevel.Administrator; }
|
||||
set
|
||||
{
|
||||
c_GlobalAccess = value;
|
||||
|
||||
if (value)
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(92));
|
||||
else
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(93));
|
||||
}
|
||||
}
|
||||
|
||||
public bool Banned
|
||||
{
|
||||
get{ return c_Banned; }
|
||||
set
|
||||
{
|
||||
c_Banned = value;
|
||||
|
||||
if (value)
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(90));
|
||||
else
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(91));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Data()
|
||||
{
|
||||
c_Friends = new ArrayList();
|
||||
c_Ignores = new ArrayList();
|
||||
c_Messages = new ArrayList();
|
||||
c_GIgnores = new ArrayList();
|
||||
c_GListens = new ArrayList();
|
||||
c_Channels = new ArrayList();
|
||||
c_IrcIgnores = new ArrayList();
|
||||
c_Sounds = new Hashtable();
|
||||
c_ChannelColors = new Hashtable();
|
||||
c_FriendsPP = 10;
|
||||
c_ChannelPP = 10;
|
||||
c_MailPP = 5;
|
||||
c_SystemC = 0x161;
|
||||
c_GlobalMC = 0x26;
|
||||
c_GlobalCC = 0x47E;
|
||||
c_GlobalGC = 0x44;
|
||||
c_GlobalFC = 0x17;
|
||||
c_GlobalWC = 0x3;
|
||||
c_StaffC = 0x3B4;
|
||||
c_AwayMsg = "";
|
||||
c_FriendsSpeech = "";
|
||||
c_ChannelsSpeech = "";
|
||||
c_MailSpeech = "";
|
||||
c_BannedUntil = DateTime.Now;
|
||||
|
||||
c_IrcRaw = true;
|
||||
}
|
||||
|
||||
public Data(Mobile m)
|
||||
{
|
||||
c_Mobile = m;
|
||||
|
||||
c_Friends = new ArrayList();
|
||||
c_Ignores = new ArrayList();
|
||||
c_Messages = new ArrayList();
|
||||
c_GIgnores = new ArrayList();
|
||||
c_GListens = new ArrayList();
|
||||
c_Channels = new ArrayList();
|
||||
c_IrcIgnores = new ArrayList();
|
||||
c_Sounds = new Hashtable();
|
||||
c_ChannelColors = new Hashtable();
|
||||
c_FriendsPP = 10;
|
||||
c_ChannelPP = 10;
|
||||
c_MailPP = 5;
|
||||
c_SystemC = 0x161;
|
||||
c_GlobalMC = 0x26;
|
||||
c_GlobalCC = 0x47E;
|
||||
c_GlobalGC = 0x44;
|
||||
c_GlobalFC = 0x17;
|
||||
c_GlobalWC = 0x3;
|
||||
c_StaffC = 0x3B4;
|
||||
c_AwayMsg = "";
|
||||
c_FriendsSpeech = "";
|
||||
c_ChannelsSpeech = "";
|
||||
c_MailSpeech = "";
|
||||
c_BannedUntil = DateTime.Now;
|
||||
|
||||
if (m.AccessLevel >= AccessLevel.Administrator)
|
||||
c_GlobalAccess = true;
|
||||
|
||||
s_Datas[m] = this;
|
||||
|
||||
foreach (Channel c in Channel.Channels)
|
||||
if (c.NewChars)
|
||||
c_Channels.Add(c.Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public bool NewMsg()
|
||||
{
|
||||
foreach (Message msg in c_Messages)
|
||||
if (!msg.Read)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool NewMsgFrom(Mobile m)
|
||||
{
|
||||
foreach (Message msg in c_Messages)
|
||||
if (!msg.Read && msg.From == m)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CheckMsg()
|
||||
{
|
||||
foreach( Message msg in c_Messages )
|
||||
if (!msg.Read)
|
||||
{
|
||||
MessageGump.SendTo(c_Mobile, msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckMsgFrom(Mobile m)
|
||||
{
|
||||
foreach(Message msg in c_Messages)
|
||||
if (!msg.Read && msg.From == m)
|
||||
{
|
||||
MessageGump.SendTo(c_Mobile, msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetSound(Mobile m)
|
||||
{
|
||||
if (c_Sounds[m] == null)
|
||||
c_Sounds[m] = c_DefaultSound;
|
||||
|
||||
return (int)c_Sounds[m];
|
||||
}
|
||||
|
||||
public void SetSound(Mobile m, int num)
|
||||
{
|
||||
if (num < 0)
|
||||
num = 0;
|
||||
|
||||
c_Sounds[m] = num;
|
||||
}
|
||||
|
||||
public int ColorFor(Channel c)
|
||||
{
|
||||
if (c_ChannelColors[c.Name] == null)
|
||||
c_ChannelColors[c.Name] = c.DefaultC;
|
||||
|
||||
return (int)c_ChannelColors[c.Name];
|
||||
}
|
||||
|
||||
public void AddFriend(Mobile m)
|
||||
{
|
||||
if (c_Friends.Contains(m) || m == c_Mobile)
|
||||
return;
|
||||
|
||||
c_Friends.Add(m);
|
||||
c_Mobile.SendMessage(c_SystemC, m.Name + " " + General.Local(73));
|
||||
|
||||
if (m.HasGump(typeof(FriendsGump)))
|
||||
General.RefreshGump(m, typeof(FriendsGump));
|
||||
if (m.HasGump(typeof(ChannelGump)))
|
||||
General.RefreshGump(m, typeof(ChannelGump));
|
||||
if (c_Mobile.HasGump(typeof(FriendsGump)))
|
||||
General.RefreshGump(c_Mobile, typeof(FriendsGump));
|
||||
if (c_Mobile.HasGump(typeof(ChannelGump)))
|
||||
General.RefreshGump(c_Mobile, typeof(ChannelGump));
|
||||
}
|
||||
|
||||
public void RemoveFriend(Mobile m)
|
||||
{
|
||||
if (!c_Friends.Contains(m))
|
||||
return;
|
||||
|
||||
c_Friends.Remove(m);
|
||||
c_Mobile.SendMessage(c_SystemC, m.Name + " " + General.Local(72));
|
||||
|
||||
if (m.HasGump(typeof(FriendsGump)))
|
||||
General.RefreshGump(m, typeof(FriendsGump));
|
||||
if (m.HasGump(typeof(ChannelGump)))
|
||||
General.RefreshGump(m, typeof(ChannelGump));
|
||||
if (c_Mobile.HasGump(typeof(FriendsGump)))
|
||||
General.RefreshGump(c_Mobile, typeof(FriendsGump));
|
||||
if (c_Mobile.HasGump(typeof(ChannelGump)))
|
||||
General.RefreshGump(c_Mobile, typeof(ChannelGump));
|
||||
}
|
||||
|
||||
public void AddIgnore(Mobile m)
|
||||
{
|
||||
if (c_Ignores.Contains(m) || m == c_Mobile)
|
||||
return;
|
||||
|
||||
c_Ignores.Add(m);
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(68) + " " + m.Name);
|
||||
}
|
||||
|
||||
public void RemoveIgnore(Mobile m)
|
||||
{
|
||||
if (!c_Ignores.Contains(m))
|
||||
return;
|
||||
|
||||
c_Ignores.Remove(m);
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(74) + " " + m.Name);
|
||||
}
|
||||
|
||||
public void AddGIgnore(Mobile m)
|
||||
{
|
||||
if (c_GIgnores.Contains(m))
|
||||
return;
|
||||
|
||||
c_GIgnores.Add(m);
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(80) + " " + m.Name);
|
||||
}
|
||||
|
||||
public void RemoveGIgnore(Mobile m)
|
||||
{
|
||||
if (!c_GIgnores.Contains(m))
|
||||
return;
|
||||
|
||||
c_GIgnores.Remove(m);
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(79) + " " + m.Name);
|
||||
}
|
||||
|
||||
public void AddGListen(Mobile m)
|
||||
{
|
||||
if (c_GListens.Contains(m))
|
||||
return;
|
||||
|
||||
c_GListens.Add(m);
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(82) + " " + m.Name);
|
||||
}
|
||||
|
||||
public void RemoveGListen(Mobile m)
|
||||
{
|
||||
if (!c_GListens.Contains(m))
|
||||
return;
|
||||
|
||||
c_GListens.Remove(m);
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(81) + " " + m.Name);
|
||||
}
|
||||
|
||||
public void AddIrcIgnore(string str)
|
||||
{
|
||||
if (c_IrcIgnores.Contains(str))
|
||||
return;
|
||||
|
||||
c_IrcIgnores.Add(str);
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(68) + " " + str);
|
||||
}
|
||||
|
||||
public void RemoveIrcIgnore(string str)
|
||||
{
|
||||
if (!c_IrcIgnores.Contains(str))
|
||||
return;
|
||||
|
||||
c_IrcIgnores.Remove(str);
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(74) + " " + str);
|
||||
}
|
||||
|
||||
public void AddMessage(Message msg)
|
||||
{
|
||||
c_Messages.Add(msg);
|
||||
|
||||
if(c_MsgSound)
|
||||
c_Mobile.SendSound(GetSound(msg.From));
|
||||
}
|
||||
|
||||
public void DeleteMessage(Message msg)
|
||||
{
|
||||
c_Messages.Remove(msg);
|
||||
|
||||
c_Mobile.SendMessage(c_SystemC, General.Local(69));
|
||||
}
|
||||
|
||||
public void Ban(TimeSpan ts)
|
||||
{
|
||||
c_BannedUntil = DateTime.Now + ts;
|
||||
c_Banned = true;
|
||||
Mobile.SendMessage(c_SystemC, General.Local(90));
|
||||
|
||||
Timer.DelayCall(ts, new TimerCallback(RemoveBan));
|
||||
}
|
||||
|
||||
public void RemoveBan()
|
||||
{
|
||||
c_BannedUntil = DateTime.Now;
|
||||
c_Banned = false;
|
||||
Mobile.SendMessage(c_SystemC, General.Local(91));
|
||||
}
|
||||
|
||||
public void Save(GenericWriter writer)
|
||||
{
|
||||
writer.Write(1); // Version
|
||||
|
||||
// version 1
|
||||
|
||||
writer.Write(c_ReadReceipt);
|
||||
writer.Write(c_QuickBar);
|
||||
|
||||
// version 0
|
||||
|
||||
writer.Write(c_Mobile);
|
||||
writer.Write((int)c_Status);
|
||||
writer.WriteMobileList(c_Friends, true);
|
||||
writer.WriteMobileList(c_Ignores, true);
|
||||
writer.WriteMobileList(c_GIgnores, true);
|
||||
writer.WriteMobileList(c_GListens, true);
|
||||
|
||||
foreach (string str in new ArrayList(c_Channels))
|
||||
if (Channel.GetByName(str) == null)
|
||||
c_Channels.Remove(str);
|
||||
|
||||
writer.Write(c_Channels.Count);
|
||||
foreach (string str in c_Channels)
|
||||
writer.Write(str);
|
||||
|
||||
writer.Write(c_Messages.Count);
|
||||
foreach (Message msg in c_Messages)
|
||||
msg.Save(writer);
|
||||
|
||||
writer.Write(c_Sounds.Count);
|
||||
foreach (Mobile m in c_Sounds.Keys)
|
||||
{
|
||||
writer.Write(m);
|
||||
writer.Write((int)c_Sounds[m]);
|
||||
}
|
||||
|
||||
foreach (string str in new ArrayList(c_ChannelColors.Keys))
|
||||
if (Channel.GetByName(str) == null)
|
||||
c_ChannelColors.Remove(str);
|
||||
|
||||
writer.Write(c_ChannelColors.Count);
|
||||
foreach (string str in c_ChannelColors.Keys)
|
||||
{
|
||||
writer.Write(str);
|
||||
writer.Write((int)c_ChannelColors[str]);
|
||||
}
|
||||
|
||||
writer.Write(c_GlobalMC);
|
||||
writer.Write(c_GlobalCC);
|
||||
writer.Write(c_GlobalGC);
|
||||
writer.Write(c_GlobalFC);
|
||||
writer.Write(c_GlobalWC);
|
||||
writer.Write(c_SystemC);
|
||||
writer.Write(c_ChannelPP);
|
||||
writer.Write(c_FriendsPP);
|
||||
writer.Write(c_MailPP);
|
||||
writer.Write(c_DefaultSound);
|
||||
writer.Write(c_StaffC);
|
||||
writer.Write(c_GlobalAccess);
|
||||
writer.Write(c_Global);
|
||||
writer.Write(c_GlobalM);
|
||||
writer.Write(c_GlobalC);
|
||||
writer.Write(c_GlobalG);
|
||||
writer.Write(c_GlobalF);
|
||||
writer.Write(c_GlobalW);
|
||||
writer.Write(c_Banned);
|
||||
writer.Write(c_FriendsOnly);
|
||||
writer.Write(c_MsgSound);
|
||||
writer.Write(c_ByRequest);
|
||||
writer.Write(c_FriendAlert);
|
||||
writer.Write(c_SevenDays);
|
||||
writer.Write(c_IrcRaw);
|
||||
writer.Write(c_AwayMsg);
|
||||
writer.Write(c_FriendsSpeech);
|
||||
writer.Write(c_ChannelsSpeech);
|
||||
writer.Write(c_MailSpeech);
|
||||
writer.Write(c_BannedUntil);
|
||||
}
|
||||
|
||||
public void Load(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if( version >= 1 )
|
||||
{
|
||||
c_ReadReceipt = reader.ReadBool();
|
||||
c_QuickBar = reader.ReadBool();
|
||||
}
|
||||
|
||||
c_Mobile = reader.ReadMobile();
|
||||
c_Status = (OnlineStatus)reader.ReadInt();
|
||||
c_Friends = reader.ReadMobileList();
|
||||
c_Ignores = reader.ReadMobileList();
|
||||
c_GIgnores = reader.ReadMobileList();
|
||||
c_GListens = reader.ReadMobileList();
|
||||
|
||||
c_Channels = new ArrayList();
|
||||
int count = reader.ReadInt();
|
||||
for (int i = 0; i < count; ++i)
|
||||
c_Channels.Add(reader.ReadString());
|
||||
|
||||
c_Messages = new ArrayList();
|
||||
Message msg;
|
||||
count = reader.ReadInt();
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
msg = new Message();
|
||||
msg.Load(reader);
|
||||
|
||||
if (msg.From != null)
|
||||
c_Messages.Add(msg);
|
||||
}
|
||||
|
||||
c_Sounds = new Hashtable();
|
||||
Mobile m;
|
||||
count = reader.ReadInt();
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
m = reader.ReadMobile();
|
||||
c_Sounds[m] = reader.ReadInt();
|
||||
}
|
||||
|
||||
c_ChannelColors = new Hashtable();
|
||||
string str = "";
|
||||
count = reader.ReadInt();
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
str = reader.ReadString();
|
||||
c_ChannelColors[str] = reader.ReadInt();
|
||||
}
|
||||
|
||||
c_GlobalMC = reader.ReadInt();
|
||||
c_GlobalCC = reader.ReadInt();
|
||||
c_GlobalGC = reader.ReadInt();
|
||||
c_GlobalFC = reader.ReadInt();
|
||||
c_GlobalWC = reader.ReadInt();
|
||||
c_SystemC = reader.ReadInt();
|
||||
c_ChannelPP = reader.ReadInt();
|
||||
c_FriendsPP = reader.ReadInt();
|
||||
c_MailPP = reader.ReadInt();
|
||||
c_DefaultSound = reader.ReadInt();
|
||||
c_StaffC = reader.ReadInt();
|
||||
c_GlobalAccess = reader.ReadBool();
|
||||
c_Global = reader.ReadBool();
|
||||
c_GlobalM = reader.ReadBool();
|
||||
c_GlobalC = reader.ReadBool();
|
||||
c_GlobalG = reader.ReadBool();
|
||||
c_GlobalF = reader.ReadBool();
|
||||
c_GlobalW = reader.ReadBool();
|
||||
c_Banned = reader.ReadBool();
|
||||
c_FriendsOnly = reader.ReadBool();
|
||||
c_MsgSound = reader.ReadBool();
|
||||
c_ByRequest = reader.ReadBool();
|
||||
c_FriendAlert = reader.ReadBool();
|
||||
c_SevenDays = reader.ReadBool();
|
||||
c_IrcRaw = reader.ReadBool();
|
||||
c_AwayMsg = reader.ReadString();
|
||||
c_FriendsSpeech = reader.ReadString();
|
||||
c_ChannelsSpeech = reader.ReadString();
|
||||
c_MailSpeech = reader.ReadString();
|
||||
c_BannedUntil = reader.ReadDateTime();
|
||||
|
||||
if (c_BannedUntil > DateTime.Now)
|
||||
Ban(c_BannedUntil - DateTime.Now);
|
||||
else
|
||||
RemoveBan();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
214
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/DefaultLocal.cs
Normal file
214
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/DefaultLocal.cs
Normal file
@@ -0,0 +1,214 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Knives.Chat3
|
||||
{
|
||||
public class DefaultLocal
|
||||
{
|
||||
public static ArrayList Load()
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
list.Add("Add Friend");
|
||||
list.Add("Remove Friend");
|
||||
list.Add("Ignore");
|
||||
list.Add("Remove Ignore");
|
||||
list.Add("Grant Global");
|
||||
list.Add("Revoke Global");
|
||||
list.Add("Ban");
|
||||
list.Add("Remove Ban");
|
||||
list.Add("Global Ignore");
|
||||
list.Add("Global Unignore");
|
||||
list.Add("Listen");
|
||||
list.Add("Remove Listen");
|
||||
list.Add("Set your away message");
|
||||
list.Add("Send Message");
|
||||
list.Add("Read Messages");
|
||||
list.Add("Client");
|
||||
list.Add("Goto");
|
||||
list.Add("Message Sound");
|
||||
list.Add("Friend and Messaging Options");
|
||||
list.Add("Online");
|
||||
list.Add("Away");
|
||||
list.Add("Busy");
|
||||
list.Add("*Unused");
|
||||
list.Add("*Unused");
|
||||
list.Add("Only friends can send messages");
|
||||
list.Add("Require friend requests");
|
||||
list.Add("Global Messages");
|
||||
list.Add("Sound on message receive");
|
||||
list.Add("Default Message Sound");
|
||||
list.Add("Friends speech shortcut");
|
||||
list.Add("Friend online alert");
|
||||
list.Add("Please select a channel to view");
|
||||
list.Add("Friends");
|
||||
list.Add("You are banned from chat");
|
||||
list.Add("You must join the channel first");
|
||||
list.Add("You are not in a chatting region");
|
||||
list.Add("You are not in a guild");
|
||||
list.Add("You are not in a faction");
|
||||
list.Add("Channels");
|
||||
list.Add("General Channel Options");
|
||||
list.Add("Options");
|
||||
list.Add("Channels speech shortcut");
|
||||
list.Add("Commands");
|
||||
list.Add("Global");
|
||||
list.Add("Global Chat");
|
||||
list.Add("Global World");
|
||||
list.Add("View All");
|
||||
list.Add("System Color");
|
||||
list.Add("Staff Color");
|
||||
list.Add("Color");
|
||||
list.Add("Channel");
|
||||
list.Add("Ignores");
|
||||
list.Add("GIgnores");
|
||||
list.Add("GListens");
|
||||
list.Add("Bans");
|
||||
list.Add("Display");
|
||||
list.Add("Mail");
|
||||
list.Add("Mail and Messaging Options");
|
||||
list.Add("Auto delete week old messages");
|
||||
list.Add("Mail speech shortcut");
|
||||
list.Add("from");
|
||||
list.Add("You must target a book");
|
||||
list.Add("Message to");
|
||||
list.Add("Recording. Press send when finished.");
|
||||
list.Add("Recording stopped");
|
||||
list.Add("Now recording. Everything you enter on the command line will appear in the message.");
|
||||
list.Add("You must have a subject and message to send");
|
||||
list.Add("Message sent to");
|
||||
list.Add("You are now ignoring");
|
||||
list.Add("You delete the message");
|
||||
list.Add("Speech command set to");
|
||||
list.Add("Speech command cleared");
|
||||
list.Add("is no longer on your friend list");
|
||||
list.Add("is now on your friend list");
|
||||
list.Add("You are no longer ignoring");
|
||||
list.Add("now has global listening access");
|
||||
list.Add("no longer has global access");
|
||||
list.Add("You ban");
|
||||
list.Add("You lift the ban from");
|
||||
list.Add("You are no longer global ignoring");
|
||||
list.Add("You are now global ignoring");
|
||||
list.Add("You are no longer globally listening to");
|
||||
list.Add("You are now globally listening to");
|
||||
list.Add("is no longer online");
|
||||
list.Add("Friend Request");
|
||||
list.Add("Do you want to add this player as a friend?");
|
||||
list.Add("You have sent a friend request to");
|
||||
list.Add("has accepted your friend request");
|
||||
list.Add("has denied your friend request");
|
||||
list.Add("You deny");
|
||||
list.Add("You are now banned from chat");
|
||||
list.Add("Your chat ban has been lifted");
|
||||
list.Add("You've been granted global access");
|
||||
list.Add("Your global access has been revoked");
|
||||
list.Add("Broadcast to all");
|
||||
list.Add("Broadcast");
|
||||
list.Add("You can send another request in");
|
||||
list.Add("You must wait a few moments between messages");
|
||||
list.Add("Enable IRC");
|
||||
list.Add("Filter and Spam Options");
|
||||
list.Add("IRC Options");
|
||||
list.Add("Misc Options");
|
||||
list.Add("The server is already attempting to connect");
|
||||
list.Add("The server is already connected");
|
||||
list.Add("IRC connection failed");
|
||||
list.Add("Attempting to connect...");
|
||||
list.Add("Connection could not be established");
|
||||
list.Add("Connecting to IRC server...");
|
||||
list.Add("Server is now connected to IRC channel");
|
||||
list.Add("IRC names list updating");
|
||||
list.Add("IRC connection down");
|
||||
list.Add("Filter violation detected:");
|
||||
list.Add("Too many search results, be more specific");
|
||||
list.Add("No matching names found");
|
||||
list.Add("Select a name");
|
||||
list.Add("Auto Connect");
|
||||
list.Add("Auto Reconnect");
|
||||
list.Add("Nickname");
|
||||
list.Add("Server");
|
||||
list.Add("Room");
|
||||
list.Add("Port");
|
||||
list.Add("White");
|
||||
list.Add("Black");
|
||||
list.Add("Blue");
|
||||
list.Add("Green");
|
||||
list.Add("Light Red");
|
||||
list.Add("Brown");
|
||||
list.Add("Purple");
|
||||
list.Add("Orange");
|
||||
list.Add("Yellow");
|
||||
list.Add("Light Green");
|
||||
list.Add("Cyan");
|
||||
list.Add("Light Cyan");
|
||||
list.Add("Light Blue");
|
||||
list.Add("Pink");
|
||||
list.Add("Grey");
|
||||
list.Add("Light Grey");
|
||||
list.Add("Select a Color");
|
||||
list.Add("Staff Color");
|
||||
list.Add("Connect");
|
||||
list.Add("Cancel Connect");
|
||||
list.Add("Close Connection");
|
||||
list.Add("Apply filter to world speech");
|
||||
list.Add("Apply filter to private messages");
|
||||
list.Add("Chat Spam");
|
||||
list.Add("Pm Spam");
|
||||
list.Add("Request Spam");
|
||||
list.Add("Filter Ban");
|
||||
list.Add("Add/Remove Filter");
|
||||
list.Add("You remove the filter:");
|
||||
list.Add("You add the filter:");
|
||||
list.Add("Filters:");
|
||||
list.Add("Show staff in channel lists");
|
||||
list.Add("Max Mailbox Size");
|
||||
list.Add("Filter Penalty");
|
||||
list.Add("None");
|
||||
list.Add("Ban");
|
||||
list.Add("Jail");
|
||||
list.Add("IRC connection is down");
|
||||
list.Add("IRC Raw");
|
||||
list.Add("Select Ban Time");
|
||||
list.Add("30 minutes");
|
||||
list.Add("1 hour");
|
||||
list.Add("12 hours");
|
||||
list.Add("1 day");
|
||||
list.Add("1 week");
|
||||
list.Add("1 month");
|
||||
list.Add("1 year");
|
||||
list.Add("Local file reloaded");
|
||||
list.Add("Reload localized text file");
|
||||
list.Add("days");
|
||||
list.Add("hours");
|
||||
list.Add("minutes");
|
||||
list.Add("is now online");
|
||||
list.Add("Error loading chat information. Please report this to Knives at kmwill23@hotmail.com");
|
||||
list.Add("Error saving chat information. Please report this to Knives at kmwill23@hotmail.com");
|
||||
list.Add("Error filtering text. Please report this to Knives at kmwill23@hotmail.com");
|
||||
list.Add("Public Channel Options");
|
||||
list.Add("Create New");
|
||||
list.Add("Please select a channel");
|
||||
list.Add("Name");
|
||||
list.Add("Style");
|
||||
list.Add("Global");
|
||||
list.Add("Regional");
|
||||
list.Add("Send Chat to IRC");
|
||||
list.Add("Add/Remove Command");
|
||||
list.Add("Error loading channel information. Please report this to Knives at kmwill23@hotmail.com");
|
||||
list.Add("Error saving channel information. Please report this to Knives at kmwill23@hotmail.com");
|
||||
list.Add("Auto join new players");
|
||||
list.Add("You have left the channel");
|
||||
list.Add("You have joined the channel");
|
||||
list.Add("You must be staff to chat here");
|
||||
list.Add("Global Guild");
|
||||
list.Add("Global Faction");
|
||||
list.Add("The message needs a subject before you can begin recording");
|
||||
list.Add("Quick Bar");
|
||||
list.Add("Message Read Receipts");
|
||||
list.Add("has read");
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/Filter.cs
Normal file
75
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/Filter.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Knives.Utils;
|
||||
|
||||
namespace Knives.Chat3
|
||||
{
|
||||
public enum FilterPenalty { None, Ban, Jail }
|
||||
|
||||
public class Filter
|
||||
{
|
||||
public static string FilterText(Mobile m, string s)
|
||||
{
|
||||
return FilterText(m, s, true);
|
||||
}
|
||||
|
||||
public static string FilterText( Mobile m, string s, bool punish )
|
||||
{try{
|
||||
|
||||
string filter = "";
|
||||
string subOne = "";
|
||||
string subTwo = "";
|
||||
string subThree = "";
|
||||
int index = 0;
|
||||
|
||||
for( int i = 0; i < Data.Filters.Count; ++i )
|
||||
{
|
||||
filter = Data.Filters[i].ToString();
|
||||
|
||||
if ( filter == "" )
|
||||
{
|
||||
Data.Filters.Remove( filter );
|
||||
continue;
|
||||
}
|
||||
|
||||
index = s.ToLower().IndexOf( filter );
|
||||
|
||||
if ( index >= 0 )
|
||||
{
|
||||
if ( m.AccessLevel == AccessLevel.Player && punish)
|
||||
{
|
||||
if (Data.FilterPenalty != FilterPenalty.None)
|
||||
m.SendMessage(Data.GetData(m).SystemC, General.Local(111) + " " + filter);
|
||||
|
||||
if (Data.FilterPenalty == FilterPenalty.Ban)
|
||||
Data.GetData(m).Ban(TimeSpan.FromMinutes(Data.FilterBanLength));
|
||||
|
||||
if (Data.FilterPenalty == FilterPenalty.Jail)
|
||||
{
|
||||
//Insert your jail method here
|
||||
}
|
||||
|
||||
if (Data.FilterPenalty != FilterPenalty.None)
|
||||
return "";
|
||||
}
|
||||
|
||||
subOne = s.Substring( 0, index );
|
||||
subTwo = "";
|
||||
|
||||
for( int ii = 0; ii < filter.Length; ++ii )
|
||||
subTwo+="*";
|
||||
|
||||
subThree = s.Substring( index+filter.Length, s.Length-filter.Length-index );
|
||||
|
||||
s = subOne + subTwo + subThree;
|
||||
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
}catch{ Errors.Report( General.Local(176) ); }
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
249
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/General.cs
Normal file
249
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/General.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Knives.Utils;
|
||||
|
||||
namespace Knives.Chat3
|
||||
{
|
||||
public class General
|
||||
{
|
||||
private static string s_Version = "3.0 Beta 6";
|
||||
private static DateTime s_ReleaseDate = new DateTime(2006, 6, 18);
|
||||
|
||||
public static string Version { get { return s_Version; } }
|
||||
public static DateTime ReleaseDate { get { return s_ReleaseDate; } }
|
||||
|
||||
private static ArrayList s_Locals = new ArrayList();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
EventSink.WorldLoad += new WorldLoadEventHandler(OnLoad);
|
||||
EventSink.WorldSave += new WorldSaveEventHandler(OnSave);
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Speech += new SpeechEventHandler(OnSpeech);
|
||||
EventSink.Login += new LoginEventHandler(OnLogin);
|
||||
EventSink.CharacterCreated += new CharacterCreatedEventHandler(OnCreate);
|
||||
}
|
||||
|
||||
private static void OnLoad()
|
||||
{
|
||||
LoadLocalFile();
|
||||
|
||||
try
|
||||
{
|
||||
Data.Load();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Errors.Report(Local(174));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Channel.Load();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Errors.Report(Local(186));
|
||||
}
|
||||
|
||||
if (Data.IrcAutoConnect)
|
||||
IrcConnection.Connection.Connect();
|
||||
}
|
||||
|
||||
private static void OnSave(WorldSaveEventArgs args)
|
||||
{
|
||||
try
|
||||
{
|
||||
Data.Save();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Errors.Report(Local(175));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Channel.Save();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Errors.Report(Local(187));
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnSpeech(SpeechEventArgs args)
|
||||
{
|
||||
if (Data.GetData(args.Mobile).Recording is SendMessageGump)
|
||||
{
|
||||
if (!args.Mobile.HasGump(typeof(SendMessageGump)))
|
||||
{
|
||||
Data.GetData(args.Mobile).Recording = null;
|
||||
return;
|
||||
}
|
||||
|
||||
((SendMessageGump)Data.GetData(args.Mobile).Recording).AddText(" " + args.Speech);
|
||||
args.Handled = true;
|
||||
args.Speech = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (Data.GetData(args.Mobile).FriendsSpeech == args.Speech)
|
||||
{
|
||||
FriendsGump.SendTo(args.Mobile);
|
||||
args.Handled = true;
|
||||
args.Speech = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (Data.GetData(args.Mobile).ChannelsSpeech == args.Speech)
|
||||
{
|
||||
ChannelGump.SendTo(args.Mobile);
|
||||
args.Handled = true;
|
||||
args.Speech = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (Data.GetData(args.Mobile).MailSpeech == args.Speech)
|
||||
{
|
||||
MailGump.SendTo(args.Mobile);
|
||||
args.Handled = true;
|
||||
args.Speech = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (Data.FilterSpeech)
|
||||
args.Speech = Filter.FilterText(args.Mobile, args.Speech, false);
|
||||
|
||||
foreach (Data data in Data.Datas.Values)
|
||||
if (data.Mobile.AccessLevel >= args.Mobile.AccessLevel && ((data.GlobalW && !data.GIgnores.Contains(args.Mobile)) || data.GListens.Contains(args.Mobile)) && !data.Mobile.InRange(args.Mobile.Location, 10))
|
||||
data.Mobile.SendMessage(data.GlobalWC, String.Format("(Global) <World> {0}: {1}", args.Mobile.Name, args.Speech));
|
||||
}
|
||||
|
||||
private static void OnLogin(LoginEventArgs args)
|
||||
{
|
||||
foreach (Data data in Data.Datas.Values)
|
||||
{
|
||||
if (data.Friends.Contains(args.Mobile) && data.FriendAlert)
|
||||
data.Mobile.SendMessage(data.SystemC, args.Mobile.Name + " " + Local(173));
|
||||
|
||||
if (data.SevenDays)
|
||||
foreach (Message msg in new ArrayList(data.Messages))
|
||||
if (msg.Received < DateTime.Now - TimeSpan.FromDays(7))
|
||||
data.Messages.Remove(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnCreate(CharacterCreatedEventArgs args)
|
||||
{
|
||||
if (args.Mobile == null)
|
||||
return;
|
||||
|
||||
Data data = Data.GetData(args.Mobile);
|
||||
|
||||
foreach (Channel c in Channel.Channels)
|
||||
if (c.NewChars)
|
||||
data.Channels.Add(c.Name);
|
||||
}
|
||||
|
||||
public static void LoadLocalFile()
|
||||
{
|
||||
s_Locals.Clear();
|
||||
|
||||
if (File.Exists("Data/ChatLocal.txt"))
|
||||
{
|
||||
using (FileStream bin = new FileStream("Data/ChatLocal.txt", FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
StreamReader reader = new StreamReader(bin);
|
||||
string text = "";
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
text = reader.ReadLine();
|
||||
|
||||
if (text == "EndOfFile")
|
||||
break;
|
||||
|
||||
s_Locals.Add(text);
|
||||
}
|
||||
catch { break; }
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
|
||||
if (s_Locals.Count == 0)
|
||||
s_Locals = DefaultLocal.Load();
|
||||
}
|
||||
|
||||
public static string Local(int num)
|
||||
{
|
||||
if (num < 0 || num >= s_Locals.Count)
|
||||
return "Local Error";
|
||||
|
||||
return s_Locals[num].ToString();
|
||||
}
|
||||
|
||||
public static void RefreshGump(Mobile m, Type type)
|
||||
{
|
||||
if (m.NetState == null)
|
||||
return;
|
||||
|
||||
foreach (Gump g in m.NetState.Gumps)
|
||||
if (g is GumpPlus && g.GetType() == type)
|
||||
{
|
||||
m.CloseGump(type);
|
||||
((GumpPlus)g).NewGump();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearGump(Mobile m, Type type)
|
||||
{
|
||||
if (m.NetState == null)
|
||||
return;
|
||||
|
||||
m.CloseGump(type);
|
||||
|
||||
foreach (Gump g in new ArrayList(m.NetState.Gumps))
|
||||
if (g.GetType() == type)
|
||||
{
|
||||
m.NetState.Gumps.Remove(g);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsInFaction(Mobile m)
|
||||
{
|
||||
if (m == null || !m.Player)
|
||||
return false;
|
||||
|
||||
return (((PlayerMobile)m).FactionPlayerState != null && ((PlayerMobile)m).FactionPlayerState.Faction != null);
|
||||
}
|
||||
|
||||
public static string FactionName(Mobile m)
|
||||
{
|
||||
if (!IsInFaction(m))
|
||||
return "";
|
||||
|
||||
return ((PlayerMobile)m).FactionPlayerState.Faction.Definition.PropName;
|
||||
}
|
||||
|
||||
public static string FactionTitle(Mobile m)
|
||||
{
|
||||
if (!IsInFaction(m))
|
||||
return "";
|
||||
|
||||
return ((PlayerMobile)m).FactionPlayerState.Rank.Title;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Knives.Utils;
|
||||
|
||||
namespace Knives.Chat3
|
||||
{
|
||||
public enum IrcColor
|
||||
{
|
||||
White = 0,
|
||||
Black = 1,
|
||||
Blue = 2,
|
||||
Green = 3,
|
||||
LightRed = 4,
|
||||
Brown = 5,
|
||||
Purple = 6,
|
||||
Orange = 7,
|
||||
Yellow = 8,
|
||||
LightGreen = 9,
|
||||
Cyan = 10,
|
||||
LightCyan = 11,
|
||||
LightBlue = 12,
|
||||
Pink = 13,
|
||||
Grey = 14,
|
||||
LightGrey = 15,
|
||||
};
|
||||
|
||||
public class IrcConnection
|
||||
{
|
||||
private static IrcConnection s_Connection = new IrcConnection();
|
||||
|
||||
public static IrcConnection Connection{ get{ return s_Connection; } }
|
||||
|
||||
private TcpClient c_Tcp;
|
||||
private Thread c_Thread;
|
||||
private StreamReader c_Reader;
|
||||
private StreamWriter c_Writer;
|
||||
private bool c_Connecting, c_Connected;
|
||||
private int c_Attempts;
|
||||
private DateTime c_LastPong;
|
||||
|
||||
public bool Connecting{ get{ return c_Connecting; } }
|
||||
public bool Connected{ get{ return c_Connected; } }
|
||||
public bool HasMoreAttempts{ get{ return c_Attempts <= Data.IrcMaxAttempts; } }
|
||||
|
||||
public IrcConnection()
|
||||
{
|
||||
}
|
||||
|
||||
public void Connect( Mobile m )
|
||||
{
|
||||
Data data = Data.GetData( m );
|
||||
|
||||
if ( c_Connecting )
|
||||
{
|
||||
m.SendMessage( data.SystemC, General.Local(102) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( c_Connected )
|
||||
{
|
||||
m.SendMessage( data.SystemC, General.Local(103) );
|
||||
return;
|
||||
}
|
||||
|
||||
Connect();
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
new Thread( new ThreadStart( ConnectTcp ) ).Start();
|
||||
}
|
||||
|
||||
public void CancelConnect()
|
||||
{
|
||||
c_Attempts = Data.IrcMaxAttempts;
|
||||
}
|
||||
|
||||
private void Reconnect()
|
||||
{
|
||||
c_Attempts++;
|
||||
|
||||
if ( !HasMoreAttempts )
|
||||
{
|
||||
c_Attempts = 1;
|
||||
BroadcastSystem( General.Local(104) );
|
||||
return;
|
||||
}
|
||||
|
||||
BroadcastSystem( General.Local(105) + c_Attempts );
|
||||
|
||||
Connect();
|
||||
}
|
||||
|
||||
private void ConnectTcp()
|
||||
{
|
||||
try{ c_Tcp = new TcpClient( Data.IrcServer, Data.IrcPort ); }
|
||||
catch
|
||||
{
|
||||
BroadcastSystem( General.Local(106) );
|
||||
|
||||
Reconnect();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ConnectStream();
|
||||
}
|
||||
|
||||
private void ConnectStream()
|
||||
{try{
|
||||
|
||||
c_Connecting = true;
|
||||
c_LastPong = DateTime.Now;
|
||||
|
||||
c_Reader = new StreamReader(c_Tcp.GetStream(), System.Text.Encoding.Default);
|
||||
c_Writer = new StreamWriter(c_Tcp.GetStream(), System.Text.Encoding.Default);
|
||||
|
||||
BroadcastSystem( General.Local(107) );
|
||||
|
||||
SendMessage(String.Format("USER {0} 1 * :Hello!", Data.IrcNick));
|
||||
SendMessage(String.Format("NICK {0}", Data.IrcNick));
|
||||
|
||||
c_Thread = new Thread(new ThreadStart(ReadStream));
|
||||
c_Thread.Start();
|
||||
|
||||
Server.Timer.DelayCall( TimeSpan.FromSeconds( 15.0 ), new Server.TimerCallback( Names ) );
|
||||
|
||||
foreach (Data data in Data.Datas.Values)
|
||||
if (data.Mobile.HasGump(typeof(SetupGump)))
|
||||
General.RefreshGump(data.Mobile, typeof(SetupGump));
|
||||
|
||||
}catch{ Errors.Report( String.Format( "IrcConnection-> ConnectStream" ) ); } }
|
||||
|
||||
private void Names()
|
||||
{
|
||||
if (c_Connected)
|
||||
SendMessage("NAMES " + Data.IrcRoom);
|
||||
else
|
||||
return;
|
||||
|
||||
Server.Timer.DelayCall( TimeSpan.FromSeconds( 15.0 ), new Server.TimerCallback( Names ) );
|
||||
}
|
||||
|
||||
private void PingPong(string str)
|
||||
{
|
||||
if (!c_Connecting && !c_Connected)
|
||||
return;
|
||||
|
||||
if (str.IndexOf("PING") != -1)
|
||||
str = str.Replace("PING", "PONG");
|
||||
else
|
||||
str = str.Replace("PONG", "PING");
|
||||
|
||||
SendMessage( str );
|
||||
}
|
||||
|
||||
public void SendMessage( string msg )
|
||||
{
|
||||
try{
|
||||
|
||||
BroadcastRaw( msg );
|
||||
|
||||
c_Writer.WriteLine( msg );
|
||||
c_Writer.Flush();
|
||||
|
||||
}catch{ Disconnect(); }
|
||||
}
|
||||
|
||||
public void SendUserMessage( Mobile m, string msg )
|
||||
{
|
||||
if ( !Connected )
|
||||
return;
|
||||
|
||||
msg = OutParse( m, m.Name + ": " + msg );
|
||||
s_Connection.SendMessage( String.Format( "PRIVMSG {0} : {1}", Data.IrcRoom, msg ));
|
||||
|
||||
BroadcastRaw( String.Format( "PRIVMSG {0} : {1}", Data.IrcRoom, msg ) );
|
||||
}
|
||||
|
||||
private string OutParse( Mobile m, string str )
|
||||
{
|
||||
if ( m.AccessLevel != AccessLevel.Player )
|
||||
return str = '\x0003' + ((int)Data.IrcStaffColor).ToString() + str;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
private void BroadcastSystem( string msg )
|
||||
{
|
||||
foreach( Data data in Data.Datas.Values )
|
||||
if ( data.Channels.Contains("IRC") && !data.Banned )
|
||||
data.Mobile.SendMessage( data.SystemC, msg );
|
||||
}
|
||||
|
||||
private void Broadcast( string name, string msg )
|
||||
{
|
||||
if (!(Channel.GetByName("IRC") is IRC))
|
||||
return;
|
||||
|
||||
((IRC)Channel.GetByName("IRC")).Broadcast(name, msg);
|
||||
}
|
||||
|
||||
private void Broadcast( Mobile m, string msg )
|
||||
{
|
||||
}
|
||||
|
||||
private void BroadcastRaw( string msg )
|
||||
{
|
||||
foreach( Data data in Data.Datas.Values )
|
||||
if ( data.IrcRaw )
|
||||
data.Mobile.SendMessage( data.SystemC, "RAW: " + msg );
|
||||
}
|
||||
|
||||
private void ReadStream()
|
||||
{try{
|
||||
|
||||
string input = "";
|
||||
|
||||
while( c_Thread.IsAlive )
|
||||
{
|
||||
input = c_Reader.ReadLine();
|
||||
|
||||
if ( input == null )
|
||||
break;
|
||||
|
||||
HandleInput( input );
|
||||
}
|
||||
|
||||
Disconnect();
|
||||
|
||||
}catch{ Disconnect(); } }
|
||||
|
||||
private void HandleInput( string str )
|
||||
{try{
|
||||
|
||||
if (str == null)
|
||||
return;
|
||||
|
||||
BroadcastRaw( str );
|
||||
|
||||
if ( str.IndexOf( "PONG" ) != -1 || str.IndexOf("PING") != -1 )
|
||||
{
|
||||
PingPong( str );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( str.IndexOf( "353" ) != -1 )
|
||||
{
|
||||
BroadcastRaw( General.Local(109) );
|
||||
|
||||
int index = str.ToLower().IndexOf( Data.IrcRoom.ToLower() ) + Data.IrcRoom.Length + 2;
|
||||
|
||||
if ( index == 1 )
|
||||
return;
|
||||
|
||||
string strList = str.Substring( index, str.Length-index );
|
||||
|
||||
string[] strs = strList.Trim().Split( ' ' );
|
||||
|
||||
Data.IrcList.Clear();
|
||||
Data.IrcList.AddRange( strs );
|
||||
Data.IrcList.Remove( Data.IrcNick );
|
||||
}
|
||||
|
||||
if (str.IndexOf("001") != -1 && c_Connecting)
|
||||
{
|
||||
c_Connected = true;
|
||||
c_Connecting = false;
|
||||
BroadcastSystem(General.Local(108));
|
||||
c_Attempts = 1;
|
||||
|
||||
SendMessage(String.Format("JOIN {0}", Data.IrcRoom));
|
||||
|
||||
foreach (Data data in Data.Datas.Values)
|
||||
if (data.Mobile.HasGump(typeof(SetupGump)))
|
||||
General.RefreshGump(data.Mobile, typeof(SetupGump));
|
||||
}
|
||||
|
||||
if (str.Length > 300)
|
||||
return;
|
||||
|
||||
if (str.IndexOf("PRIVMSG") != -1)
|
||||
{
|
||||
string parOne = str.Substring( 1, str.IndexOf( "!" )-1 );
|
||||
|
||||
string parThree = str.Substring( str.IndexOf( "!" )+1, str.Length-str.IndexOf("!")-(str.Length-str.IndexOf("PRIVMSG"))-1);
|
||||
|
||||
int index = 0;
|
||||
|
||||
index = str.ToLower().IndexOf( Data.IrcRoom.ToLower() ) + Data.IrcRoom.Length + 2;
|
||||
|
||||
if ( index == 1 )
|
||||
return;
|
||||
|
||||
string parTwo = str.Substring( index, str.Length-index );
|
||||
|
||||
if ( parTwo.IndexOf( "ACTION" ) != -1 )
|
||||
{
|
||||
index = parTwo.IndexOf( "ACTION" ) + 7;
|
||||
parTwo = parTwo.Substring( index, parTwo.Length-index );
|
||||
str = String.Format( "<{0}> {1} {2}", Data.IrcRoom, parOne, parTwo );
|
||||
}
|
||||
else
|
||||
str = String.Format( "<{0}> {1}: {2}", Data.IrcRoom, parOne, parTwo );
|
||||
|
||||
Broadcast( parOne, str );
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) { Errors.Report(String.Format("IrcConnection-> HandleInput")); Console.WriteLine(e.Message); }}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
Disconnect( true );
|
||||
}
|
||||
|
||||
public void Disconnect(bool reconn)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (c_Connected)
|
||||
BroadcastSystem(General.Local(110));
|
||||
|
||||
c_Connected = false;
|
||||
c_Connecting = false;
|
||||
|
||||
if (c_Thread != null)
|
||||
{
|
||||
c_Thread.Abort();
|
||||
c_Thread = null;
|
||||
}
|
||||
if (c_Reader != null)
|
||||
c_Reader.Close();
|
||||
if (c_Writer != null)
|
||||
c_Writer.Close();
|
||||
if (c_Tcp != null)
|
||||
c_Tcp.Close();
|
||||
|
||||
if (reconn)
|
||||
Reconnect();
|
||||
|
||||
foreach (Data data in Data.Datas.Values)
|
||||
if (data.Mobile.HasGump(typeof(SetupGump)))
|
||||
General.RefreshGump(data.Mobile, typeof(SetupGump));
|
||||
}
|
||||
catch { Errors.Report(String.Format("IrcConnection-> Disconnect")); }
|
||||
}
|
||||
}
|
||||
}
|
||||
89
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/Message.cs
Normal file
89
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/Message.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
|
||||
namespace Knives.Chat3
|
||||
{
|
||||
public enum MsgType { Normal, Invite, System }
|
||||
|
||||
public class Message
|
||||
{
|
||||
public static bool CanMessage(Mobile from, Mobile to)
|
||||
{
|
||||
if (from.AccessLevel > to.AccessLevel)
|
||||
return true;
|
||||
|
||||
Data df = Data.GetData(from);
|
||||
Data dt = Data.GetData(to);
|
||||
|
||||
if (df.Banned || dt.Banned)
|
||||
return false;
|
||||
if (df.FriendsOnly && !df.Friends.Contains(to))
|
||||
return false;
|
||||
if (dt.FriendsOnly && !dt.Friends.Contains(from))
|
||||
return false;
|
||||
if (df.Ignores.Contains(to))
|
||||
return false;
|
||||
if (dt.Ignores.Contains(from))
|
||||
return false;
|
||||
if (dt.Messages.Count >= Data.MaxMsgs)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Mobile c_From;
|
||||
private string c_Msg, c_Subject;
|
||||
private MsgType c_Type;
|
||||
private DateTime c_Received;
|
||||
private bool c_Read;
|
||||
|
||||
public Mobile From { get { return c_From; } }
|
||||
public string Msg { get { return c_Msg; } }
|
||||
public string Subject { get { return c_Subject; } }
|
||||
public MsgType Type { get { return c_Type; } }
|
||||
public DateTime Received { get { return c_Received; } }
|
||||
public bool Read { get { return c_Read; } set { c_Read = value; } }
|
||||
|
||||
public Message()
|
||||
{
|
||||
c_Msg = "";
|
||||
c_Subject = "";
|
||||
}
|
||||
|
||||
public Message(Mobile from, string sub, string msg, MsgType type)
|
||||
{
|
||||
c_From = from;
|
||||
c_Msg = msg;
|
||||
c_Subject = sub;
|
||||
c_Type = type;
|
||||
|
||||
c_Received = DateTime.Now;
|
||||
}
|
||||
|
||||
public void Save(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0); // Version
|
||||
|
||||
writer.Write(c_From);
|
||||
writer.Write(c_Msg);
|
||||
writer.Write(c_Subject);
|
||||
writer.Write((int)c_Type);
|
||||
writer.Write(c_Received);
|
||||
writer.Write(c_Read);
|
||||
}
|
||||
|
||||
public void Load(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
c_From = reader.ReadMobile();
|
||||
c_Msg = reader.ReadString();
|
||||
c_Subject = reader.ReadString();
|
||||
c_Type = (MsgType)reader.ReadInt();
|
||||
c_Received = reader.ReadDateTime();
|
||||
c_Read = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
462
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/Profile.cs
Normal file
462
Scripts/SubSystem/Knives Chat 3.0 Beta 6/General/Profile.cs
Normal file
@@ -0,0 +1,462 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Knives.Utils;
|
||||
|
||||
namespace Knives.Chat3
|
||||
{
|
||||
public class Profile
|
||||
{
|
||||
public static void Insert(Mobile m, GumpPlus g, int x, int y)
|
||||
{
|
||||
if ( m == null )
|
||||
return;
|
||||
|
||||
Data data = Data.GetData(g.Owner);
|
||||
|
||||
int oldY = y;
|
||||
|
||||
g.AddHtml(x, y += 10, 300, 21, HTML.White + "<CENTER>" + Server.Misc.Titles.ComputeTitle(g.Owner, m), false, false);
|
||||
|
||||
if (m.AccessLevel != AccessLevel.Player)
|
||||
g.AddHtml(x, y += 20, 300, 21, HTML.White + "<CENTER>" + m.AccessLevel, false, false);
|
||||
else
|
||||
{
|
||||
if (m.Guild != null)
|
||||
g.AddHtml(x, y += 20, 300, 21, HTML.White + "<CENTER>[" + m.Guild.Abbreviation + "] " + m.GuildTitle, false, false);
|
||||
if(General.IsInFaction(m))
|
||||
g.AddHtml(x, y += 20, 300, 21, HTML.White + "<CENTER>" + General.FactionName(m) + " " + General.FactionTitle(m), false, false);
|
||||
}
|
||||
|
||||
g.AddButton(x + 20, (y += 30) + 3, 0x2716, 0x2716, "Friend", new TimerStateCallback(Friend), new object[] { data, m, g });
|
||||
g.AddHtml(x + 40, y, 120, 21, HTML.White + (data.Friends.Contains(m) ? General.Local(1) : General.Local(0)), false, false);
|
||||
|
||||
g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Ignore", new TimerStateCallback(Ignore), new object[] { data, m, g });
|
||||
g.AddHtml(x + 190, y, 120, 21, HTML.White + (data.Ignores.Contains(m) ? General.Local(3) : General.Local(2)), false, false);
|
||||
|
||||
if (Chat3.Message.CanMessage(data.Mobile, m))
|
||||
{
|
||||
g.AddButton(x + 20, (y += 20) + 3, 0x2716, 0x2716, "Send Message", new TimerStateCallback(Message), new object[] { data, m, g });
|
||||
g.AddHtml(x + 40, y, 120, 21, HTML.White + General.Local(13), false, false);
|
||||
}
|
||||
|
||||
if (data.Mobile.AccessLevel >= AccessLevel.GameMaster && data.Mobile.AccessLevel > m.AccessLevel)
|
||||
{
|
||||
g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Read Messages", new TimerStateCallback(ReadMessages), new object[] { data, m, g });
|
||||
g.AddHtml(x + 190, y, 120, 21, HTML.Red + General.Local(14), false, false, false);
|
||||
}
|
||||
|
||||
y += 20;
|
||||
|
||||
if (data.Mobile.AccessLevel == AccessLevel.Administrator && m.AccessLevel != AccessLevel.Administrator && m.AccessLevel != AccessLevel.Player)
|
||||
{
|
||||
g.AddButton(x + 20, y + 3, 0x2716, 0x2716, "Global Access", new TimerStateCallback(GlobalAccess), new object[] { m, g });
|
||||
g.AddHtml(x + 40, y, 120, 21, HTML.LightPurple + (Data.GetData(m).GlobalAccess ? General.Local(5) : General.Local(4)), false, false, false);
|
||||
}
|
||||
|
||||
if (data.Mobile.AccessLevel >= AccessLevel.GameMaster && m.AccessLevel == AccessLevel.Player)
|
||||
{
|
||||
g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Ban", new TimerStateCallback(Ban), new object[] { m, g });
|
||||
g.AddHtml(x + 190, y, 120, 21, HTML.Red + (Data.GetData(m).Banned ? General.Local(7) : General.Local(6)), false, false, false);
|
||||
}
|
||||
|
||||
if (data.GlobalAccess)
|
||||
{
|
||||
y += 20;
|
||||
|
||||
if (data.Global)
|
||||
{
|
||||
g.AddButton(x + 20, y + 3, 0x2716, 0x2716, "Global Ignore", new TimerStateCallback(GIgnore), new object[] { data, m, g });
|
||||
g.AddHtml(x + 40, y, 120, 21, HTML.Red + (data.GIgnores.Contains(m) ? General.Local(9) : General.Local(8)), false, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Global Listen", new TimerStateCallback(GListen), new object[] { data, m, g });
|
||||
g.AddHtml(x + 190, y, 120, 21, HTML.Red + (data.GListens.Contains(m) ? General.Local(11) : General.Local(10)), false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.Mobile.AccessLevel >= AccessLevel.GameMaster && m.NetState != null)
|
||||
{
|
||||
g.AddButton(x + 20, (y += 20) + 3, 0x2716, 0x2716, "Client", new TimerStateCallback(Client), new object[] { data, m, g });
|
||||
g.AddHtml(x + 40, y, 120, 21, HTML.Red + General.Local(15), false, false, false);
|
||||
|
||||
g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Goto", new TimerStateCallback(Goto), new object[] { data, m, g });
|
||||
g.AddHtml(x + 190, y, 120, 21, HTML.Red + General.Local(16), false, false, false);
|
||||
}
|
||||
|
||||
if (data.MsgSound)
|
||||
{
|
||||
g.AddHtml(x, y+=25, 300, 21, HTML.White + "<CENTER>" + General.Local(17), false, false);
|
||||
g.AddImageTiled(x+125, y+=25, 50, 21, 0xBBA);
|
||||
g.AddTextField(x+125, y, 50, 21, 0x480, 0, data.GetSound(m).ToString());
|
||||
g.AddButton(x + 185, y+3, 0x15E1, 0x15E5, "Play Sound", new TimerStateCallback(PlaySound), new object[] { data, m, g });
|
||||
g.AddButton(x + 110, y, 0x983, 0x983, "Sound Up", new TimerStateCallback(SoundUp), new object[] { data, m, g });
|
||||
g.AddButton(x + 110, y+10, 0x985, 0x985, "Sound Down", new TimerStateCallback(SoundDown), new object[] { data, m, g });
|
||||
}
|
||||
|
||||
g.Entries.Insert( 0, new GumpBackground(x, oldY, 300, y+40-oldY, 0x1400));
|
||||
}
|
||||
|
||||
private static void Friend(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
if (Data.GetData(m).ByRequest && !data.Friends.Contains(m))
|
||||
{
|
||||
if (!TrackSpam.LogSpam(g.Owner, "Request " + m.Name, TimeSpan.FromHours(24)))
|
||||
{
|
||||
TimeSpan ts = TrackSpam.NextAllowedIn(g.Owner, "Request " + m.Name, TimeSpan.FromHours(Data.RequestSpam));
|
||||
string txt = (ts.Days != 0 ? ts.Days + " " + General.Local(170) + " " : "") + (ts.Hours != 0 ? ts.Hours + " " + General.Local(171) + " " : "") + (ts.Minutes != 0 ? ts.Minutes + " " + General.Local(172) + " " : "");
|
||||
|
||||
g.Owner.SendMessage(data.SystemC, General.Local(96) + " " + txt);
|
||||
g.NewGump();
|
||||
return;
|
||||
}
|
||||
|
||||
Data.GetData(m).AddMessage(new Message(g.Owner, General.Local(84), General.Local(85), MsgType.Invite));
|
||||
|
||||
g.Owner.SendMessage(data.SystemC, General.Local(86) + " " + m.Name);
|
||||
|
||||
if (m.HasGump(typeof(FriendsGump)))
|
||||
General.RefreshGump(m, typeof(FriendsGump));
|
||||
else
|
||||
FriendsGump.SendTo(m, true);
|
||||
|
||||
General.RefreshGump(m, typeof(MailGump));
|
||||
|
||||
g.NewGump();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.Friends.Contains(m))
|
||||
data.RemoveFriend(m);
|
||||
else
|
||||
data.AddFriend(m);
|
||||
|
||||
g.NewGump();
|
||||
}
|
||||
|
||||
private static void Ignore(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
if (data.Ignores.Contains(m))
|
||||
data.RemoveIgnore(m);
|
||||
else
|
||||
data.AddIgnore(m);
|
||||
|
||||
g.NewGump();
|
||||
}
|
||||
|
||||
private static void Message(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
g.NewGump();
|
||||
|
||||
if (Chat3.Message.CanMessage(data.Mobile, m))
|
||||
SendMessageGump.SendTo(data.Mobile, m);
|
||||
}
|
||||
|
||||
private static void ReadMessages(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
g.NewGump();
|
||||
|
||||
MailGump.SendTo(data.Mobile, m);
|
||||
}
|
||||
|
||||
private static void GlobalAccess(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 2 || !(obj[0] is Mobile) || !(obj[1] is GumpPlus))
|
||||
return;
|
||||
|
||||
Mobile m = (Mobile)obj[0];
|
||||
GumpPlus g = (GumpPlus)obj[1];
|
||||
|
||||
Data.GetData(m).GlobalAccess = !Data.GetData(m).GlobalAccess;
|
||||
|
||||
if (Data.GetData(m).GlobalAccess)
|
||||
g.Owner.SendMessage(Data.GetData(g.Owner).SystemC, m.Name + " " + General.Local(75));
|
||||
else
|
||||
g.Owner.SendMessage(Data.GetData(g.Owner).SystemC, m.Name + " " + General.Local(76));
|
||||
|
||||
g.NewGump();
|
||||
}
|
||||
|
||||
private static void Ban(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 2 || !(obj[0] is Mobile) || !(obj[1] is GumpPlus))
|
||||
return;
|
||||
|
||||
Mobile m = (Mobile)obj[0];
|
||||
GumpPlus g = (GumpPlus)obj[1];
|
||||
|
||||
if (Data.GetData(m).Banned)
|
||||
{
|
||||
Data.GetData(m).RemoveBan();
|
||||
g.Owner.SendMessage(Data.GetData(g.Owner).SystemC, General.Local(78) + " " + m.Name);
|
||||
g.NewGump();
|
||||
}
|
||||
else
|
||||
new InternalGump(m, g);
|
||||
}
|
||||
|
||||
private static void GIgnore(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
if (data.GIgnores.Contains(m))
|
||||
data.RemoveGIgnore(m);
|
||||
else
|
||||
data.AddGIgnore(m);
|
||||
|
||||
g.NewGump();
|
||||
}
|
||||
|
||||
private static void GListen(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
if (data.GListens.Contains(m))
|
||||
data.RemoveGListen(m);
|
||||
else
|
||||
data.AddGListen(m);
|
||||
|
||||
g.NewGump();
|
||||
}
|
||||
|
||||
private static void Client(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
g.NewGump();
|
||||
|
||||
if (m.NetState == null)
|
||||
data.Mobile.SendMessage(data.SystemC, m.Name + " " + General.Local(83));
|
||||
else
|
||||
data.Mobile.SendGump(new ClientGump(data.Mobile, m.NetState));
|
||||
}
|
||||
|
||||
private static void Goto(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
if (m.NetState == null)
|
||||
data.Mobile.SendMessage(data.SystemC, m.Name + " " + General.Local(83));
|
||||
else
|
||||
{
|
||||
data.Mobile.Location = m.Location;
|
||||
data.Mobile.Map = m.Map;
|
||||
}
|
||||
|
||||
g.NewGump();
|
||||
}
|
||||
|
||||
private static void PlaySound(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
data.SetSound(m, Utility.ToInt32(g.GetTextField(0)));
|
||||
data.Mobile.SendSound(data.GetSound(m));
|
||||
|
||||
g.NewGump();
|
||||
}
|
||||
|
||||
private static void SoundUp(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
data.SetSound(m, data.GetSound(m) + 1);
|
||||
|
||||
g.NewGump();
|
||||
}
|
||||
|
||||
private static void SoundDown(object o)
|
||||
{
|
||||
if (!(o is object[]))
|
||||
return;
|
||||
|
||||
object[] obj = (object[])o;
|
||||
|
||||
if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus))
|
||||
return;
|
||||
|
||||
Data data = (Data)obj[0];
|
||||
Mobile m = (Mobile)obj[1];
|
||||
GumpPlus g = (GumpPlus)obj[2];
|
||||
|
||||
data.SetSound(m, data.GetSound(m) - 1);
|
||||
|
||||
g.NewGump();
|
||||
}
|
||||
|
||||
|
||||
private class InternalGump : GumpPlus
|
||||
{
|
||||
private GumpPlus c_Gump;
|
||||
private Mobile c_Target;
|
||||
|
||||
public InternalGump(Mobile m, GumpPlus g) : base(g.Owner, 100, 100)
|
||||
{
|
||||
c_Gump = g;
|
||||
c_Target = m;
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
protected override void BuildGump()
|
||||
{
|
||||
int y = 10;
|
||||
|
||||
AddHtml(0, y, 150, 21, HTML.White + "<CENTER>" + General.Local(160), false, false);
|
||||
|
||||
AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(161), false, false);
|
||||
AddButton(25, y + 3, 0x2716, 0x2716, "30 minutes", new TimerStateCallback(BanTime), TimeSpan.FromMinutes(30));
|
||||
AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(162), false, false);
|
||||
AddButton(25, y + 3, 0x2716, 0x2716, "1 hour", new TimerStateCallback(BanTime), TimeSpan.FromHours(1));
|
||||
AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(163), false, false);
|
||||
AddButton(25, y + 3, 0x2716, 0x2716, "12 hours", new TimerStateCallback(BanTime), TimeSpan.FromHours(12));
|
||||
AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(164), false, false);
|
||||
AddButton(25, y + 3, 0x2716, 0x2716, "1 day", new TimerStateCallback(BanTime), TimeSpan.FromDays(1));
|
||||
AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(165), false, false);
|
||||
AddButton(25, y + 3, 0x2716, 0x2716, "1 week", new TimerStateCallback(BanTime), TimeSpan.FromDays(7));
|
||||
AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(166), false, false);
|
||||
AddButton(25, y + 3, 0x2716, 0x2716, "1 month", new TimerStateCallback(BanTime), TimeSpan.FromDays(30));
|
||||
AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(167), false, false);
|
||||
AddButton(25, y + 3, 0x2716, 0x2716, "1 year", new TimerStateCallback(BanTime), TimeSpan.FromDays(365));
|
||||
|
||||
Entries.Insert(0, new GumpBackground(0, 0, 150, y + 40, 0x1400));
|
||||
}
|
||||
|
||||
private void BanTime(object o)
|
||||
{
|
||||
if (!(o is TimeSpan))
|
||||
return;
|
||||
|
||||
Data.GetData(c_Target).Ban((TimeSpan)o);
|
||||
Owner.SendMessage(Data.GetData(Owner).SystemC, General.Local(77) + " " + c_Target.Name);
|
||||
|
||||
c_Gump.NewGump();
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
c_Gump.NewGump();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Knives.Utils;
|
||||
|
||||
namespace Knives.Chat3
|
||||
{
|
||||
public class TrackSpam
|
||||
{
|
||||
private static Hashtable s_Log = new Hashtable();
|
||||
|
||||
public static bool LogSpam( Mobile m, string type, TimeSpan limit )
|
||||
{
|
||||
if ( s_Log.Contains( m ) )
|
||||
{
|
||||
Hashtable table = (Hashtable)s_Log[m];
|
||||
|
||||
if ( table.Contains( type ) )
|
||||
{
|
||||
if ( (DateTime)table[type] > DateTime.Now-limit )
|
||||
return false;
|
||||
|
||||
table[type] = DateTime.Now;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Hashtable table = new Hashtable();
|
||||
table[type] = DateTime.Now;
|
||||
s_Log[m] = table;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static TimeSpan NextAllowedIn( Mobile m, string type, TimeSpan limit )
|
||||
{
|
||||
if ( s_Log[m] == null )
|
||||
return TimeSpan.FromSeconds( 1 );
|
||||
|
||||
Hashtable table = (Hashtable)s_Log[m];
|
||||
|
||||
if ( table[type] == null || (DateTime)table[type]+limit < DateTime.Now )
|
||||
return TimeSpan.FromSeconds( 1 );
|
||||
|
||||
return (DateTime)table[type]+limit-DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user