mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 23:31:13 -05:00
Chat history stuff
fixed kills not saving
This commit is contained in:
@ -12,6 +12,86 @@ namespace StatsPlugin
|
||||
{
|
||||
public class ChatDatabase : Database
|
||||
{
|
||||
private string[] CommonWords = new string[] { "for",
|
||||
"with",
|
||||
"from",
|
||||
"about",
|
||||
"into",
|
||||
"over",
|
||||
"after",
|
||||
"that",
|
||||
"not",
|
||||
"you",
|
||||
"this",
|
||||
"but",
|
||||
"his",
|
||||
"they",
|
||||
"her",
|
||||
"she",
|
||||
"will",
|
||||
"one",
|
||||
"all",
|
||||
"would",
|
||||
"there",
|
||||
"their",
|
||||
"have",
|
||||
"say",
|
||||
"get",
|
||||
"make",
|
||||
"know",
|
||||
"take",
|
||||
"see",
|
||||
"come",
|
||||
"think",
|
||||
"look",
|
||||
"want",
|
||||
"give",
|
||||
"use",
|
||||
"find",
|
||||
"tell",
|
||||
"ask",
|
||||
"work",
|
||||
"seem",
|
||||
"feel",
|
||||
"try",
|
||||
"leave",
|
||||
"call",
|
||||
"good",
|
||||
"new",
|
||||
"first",
|
||||
"last",
|
||||
"long",
|
||||
"great",
|
||||
"little",
|
||||
"own",
|
||||
"other",
|
||||
"old",
|
||||
"right",
|
||||
"big",
|
||||
"high",
|
||||
"small",
|
||||
"large",
|
||||
"next",
|
||||
"early",
|
||||
"young",
|
||||
"important",
|
||||
"few",
|
||||
"public",
|
||||
"same",
|
||||
"able",
|
||||
"the",
|
||||
"and",
|
||||
"that",
|
||||
"have",
|
||||
"this",
|
||||
"one",
|
||||
"would",
|
||||
"yeah",
|
||||
"yah",
|
||||
"why",
|
||||
"who" ,
|
||||
"when"};
|
||||
|
||||
public ChatDatabase(string FN) : base(FN)
|
||||
{
|
||||
}
|
||||
@ -65,6 +145,9 @@ namespace StatsPlugin
|
||||
|
||||
public void AddChatHistory(int clientID, int serverID, string message)
|
||||
{
|
||||
if (message.Length < 3)
|
||||
return;
|
||||
|
||||
var chat = new Dictionary<string, object>()
|
||||
{
|
||||
{ "ClientID", clientID },
|
||||
@ -75,20 +158,22 @@ namespace StatsPlugin
|
||||
|
||||
Insert("CHATHISTORY", chat);
|
||||
|
||||
message.Split(' ').Where(word => word.Length >= 3).Any(word =>
|
||||
{
|
||||
word = word.ToLower();
|
||||
Insert("WORDSTATS", new Dictionary<string, object>() { { "Word", word } }, true);
|
||||
// shush :^)
|
||||
ExecuteNonQuery($"UPDATE WORDSTATS SET Count = Count + 1 WHERE Word='{word.CleanChars()}'");
|
||||
return true;
|
||||
}
|
||||
);
|
||||
var eachWord = message.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Where (word => word.Length >= 3)
|
||||
.Where(word => CommonWords.FirstOrDefault(c => c == word.ToLower()) == null)
|
||||
.ToList();
|
||||
|
||||
foreach (string _word in eachWord)
|
||||
{
|
||||
string word = _word.ToLower();
|
||||
Insert("WORDSTATS", new Dictionary<string, object>() { { "Word", word } }, true);
|
||||
UpdateIncrement("WORDSTATS", "Count", new Dictionary<string, object>() { { "Count", 1 } }, new KeyValuePair<string, object>("Word", word));
|
||||
}
|
||||
}
|
||||
|
||||
public KeyValuePair<string, int>[] GetWords()
|
||||
{
|
||||
var result = GetDataTable("SELECT * FROM WORDSTATS ORDER BY Count desc LIMIT 100");
|
||||
var result = GetDataTable("SELECT * FROM WORDSTATS ORDER BY Count desc LIMIT 200");
|
||||
return result.Select().Select(w => new KeyValuePair<string, int>(w["Word"].ToString(), Convert.ToInt32(w["Count"].ToString()))).ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ namespace StatsPlugin.Chat
|
||||
{
|
||||
public class ChatPage : HTMLPage
|
||||
{
|
||||
public ChatPage() : base(false) { }
|
||||
|
||||
public override string GetContent(NameValueCollection querySet, IDictionary<string, string> headers)
|
||||
{
|
||||
StringBuilder S = new StringBuilder();
|
||||
@ -27,7 +25,7 @@ namespace StatsPlugin.Chat
|
||||
return S.ToString();
|
||||
}
|
||||
|
||||
public override string GetName() => "Chat Stats";
|
||||
public override string GetName() => "Word Cloud";
|
||||
public override string GetPath() => "/chat";
|
||||
}
|
||||
|
||||
@ -68,11 +66,20 @@ namespace StatsPlugin.Chat
|
||||
|
||||
public HttpResponse GetPage(NameValueCollection querySet, IDictionary<string, string> headers)
|
||||
{
|
||||
int clientID = Convert.ToInt32(querySet["clientid"]);
|
||||
var client = Stats.ManagerInstance.GetClientDatabase().GetPlayer(clientID);
|
||||
|
||||
HttpResponse resp = new HttpResponse()
|
||||
{
|
||||
contentType = GetContentType(),
|
||||
content = Stats.ChatDB.GetChatForPlayer(Convert.ToInt32(querySet["clientid"])).ToArray(),
|
||||
content = Stats.ChatDB.GetChatForPlayer(clientID).ToArray().Select(c => new
|
||||
{
|
||||
ClientID = c.ClientID,
|
||||
ServerID = c.ServerID,
|
||||
Message = c.Message,
|
||||
TimeSent = c.TimeSent,
|
||||
Client = client
|
||||
}),
|
||||
additionalHeaders = new Dictionary<string, string>()
|
||||
};
|
||||
|
||||
|
@ -316,7 +316,6 @@ namespace StatsPlugin
|
||||
//S.Logger.WriteInfo($"{E.Origin.Name} killed {E.Target.Name} with a {killEvent.Weapon} from a distance of {Vector3.Distance(killEvent.KillOrigin, killEvent.DeathOrigin)} with {killEvent.Damage} damage, at {killEvent.HitLoc}");
|
||||
var cs = statLists.Find(x => x.Port == S.GetPort());
|
||||
cs.playerStats.AddKill(killEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
Player Killer = E.Origin;
|
||||
|
Reference in New Issue
Block a user