1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-13 00:28:10 -05:00

abstracting rcon parsing and event parsing

changed Event to GameEvent
finally fixed the stats NaN
check ip for bans
consolidated console, profile, and logout into dropdown
make sure game is iw4 before using :^ in say
fix pm not showing from name if in web console
show time left of temban on profile
This commit is contained in:
RaidMax
2018-04-13 01:32:30 -05:00
parent 15372d0726
commit b9c11d48c2
34 changed files with 519 additions and 272 deletions

View File

@ -7,9 +7,9 @@ using SharedLibraryCore.Objects;
namespace SharedLibraryCore
{
public class Event
public class GameEvent
{
public enum GType
public enum EventType
{
//FROM SERVER
Start,
@ -38,7 +38,7 @@ namespace SharedLibraryCore
Death,
}
public Event(GType t, string d, Player O, Player T, Server S)
public GameEvent(EventType t, string d, Player O, Player T, Server S)
{
Type = t;
Data = d?.Trim();
@ -47,59 +47,10 @@ namespace SharedLibraryCore
Owner = S;
}
public static Event ParseEventString(String[] line, Server SV)
{
#if DEBUG == false
try
#endif
{
string removeTime = Regex.Replace(line[0], @"[0-9]+:[0-9]+\ ", "");
if (removeTime[0] == 'K')
{
StringBuilder Data = new StringBuilder();
if (line.Length > 9)
{
for (int i = 9; i < line.Length; i++)
Data.Append(line[i] + ";");
}
if (!SV.CustomCallback)
return new Event(GType.Script, Data.ToString(), SV.ParseClientFromString(line, 6), SV.ParseClientFromString(line, 2), SV);
}
if (line[0].Substring(line[0].Length - 3).Trim() == "say")
{
Regex rgx = new Regex("[^a-zA-Z0-9 -! -_]");
string message = rgx.Replace(line[4], "");
return new Event(GType.Say, message.StripColors(), SV.ParseClientFromString(line, 2), null, SV) { Message = message };
}
if (removeTime.Contains("ScriptKill"))
{
return new Event(GType.Script, String.Join(";", line), SV.Players.First(p => p != null && p.NetworkId == line[1].ConvertLong()), SV.Players.First(p => p != null && p.NetworkId == line[2].ConvertLong()), SV);
}
if (removeTime.Contains("ExitLevel"))
return new Event(GType.MapEnd, line[0], new Player() { ClientId = 1 }, null, SV);
if (removeTime.Contains("InitGame"))
return new Event(GType.MapChange, line[0], new Player() { ClientId = 1 }, null, SV);
public GameEvent() { }
return null;
}
#if DEBUG == false
catch (Exception E)
{
SV.Manager.GetLogger().WriteError("Error requesting event " + E.Message);
return null;
}
#endif
}
public GType Type;
public EventType Type;
public string Data; // Data is usually the message sent by player
public string Message;
public Player Origin;