mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-11 15:52:25 -05:00
moved stats to a plugin!
This commit is contained in:
@ -424,65 +424,6 @@ namespace IW4MAdmin
|
||||
}
|
||||
}
|
||||
|
||||
class _Stats : Command
|
||||
{
|
||||
public _Stats(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
|
||||
|
||||
public override void Execute(Event E)
|
||||
{
|
||||
if (E.Target == null)
|
||||
{
|
||||
if (E.Target.stats == null)
|
||||
E.Origin.Tell("You do not have any stats!");
|
||||
else
|
||||
E.Origin.Tell(String.Format("^5{0} ^7KILLS | ^5{1} ^7DEATHS | ^5{2} ^7KDR | ^5{3} ^7SKILL", E.Origin.stats.Kills, E.Origin.stats.Deaths, E.Origin.stats.KDR, E.Origin.stats.Skill));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
E.Target.stats = E.Owner.statDB.getStats(E.Target.databaseID);
|
||||
if (E.Target.stats == null)
|
||||
E.Origin.Tell("That person does not have any stats at this time!");
|
||||
else
|
||||
E.Origin.Tell(String.Format("[^3{4}^7] ^5{0} ^7KILLS | ^5{1} ^7DEATHS | ^5{2} ^7KDR | ^5{3} ^7SKILL", E.Target.stats.Kills, E.Target.stats.Deaths, E.Target.stats.KDR, E.Target.stats.Skill, E.Target.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TopStats : Command
|
||||
{
|
||||
public TopStats(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
|
||||
|
||||
public override void Execute(Event E)
|
||||
{
|
||||
List<Stats> Top = E.Owner.statDB.topStats();
|
||||
List<Player> TopP = new List<Player>();
|
||||
|
||||
foreach (Stats S in Top)
|
||||
{
|
||||
Player P = E.Owner.clientDB.getPlayer(S.statIndex);
|
||||
if (P != null && P.Level != Player.Permission.Banned)
|
||||
{
|
||||
P.stats = S;
|
||||
TopP.Add(P);
|
||||
}
|
||||
}
|
||||
|
||||
if (TopP.Count > 0)
|
||||
{
|
||||
E.Origin.Tell("^1TOP PLAYERS");
|
||||
foreach (Player P in TopP)
|
||||
{
|
||||
if (P != null)
|
||||
E.Origin.Tell(String.Format("^3{0}^7 - ^5{1} ^7KDR | ^5{2} ^7SKILL", P.Name, P.stats.KDR, P.stats.Skill));
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
E.Origin.Tell("There are no top players yet!");
|
||||
}
|
||||
}
|
||||
|
||||
class Reload : Command
|
||||
{
|
||||
public Reload(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
|
||||
|
@ -128,15 +128,15 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.manifest" />
|
||||
<None Include="lib\AdminInterface.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="lib\Kayak.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="lib\System.Data.SQLite.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="lib\AdminInterface.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="lib\SharedLibary.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
@ -10,14 +10,14 @@ namespace IW4MAdmin
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static public double Version = 0.92;
|
||||
static public double latestVersion;
|
||||
static public bool usingMemory = true;
|
||||
static public double Version { get; private set; }
|
||||
static private Manager serverManager;
|
||||
static private IW4MAdmin_Web.WebFront frontEnd;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Version = 0.95;
|
||||
double latestVersion = 0;
|
||||
handler = new ConsoleEventDelegate(OnProcessExit);
|
||||
SetConsoleCtrlHandler(handler, true);
|
||||
|
||||
@ -66,6 +66,7 @@ namespace IW4MAdmin
|
||||
if (S == null)
|
||||
continue;
|
||||
|
||||
S.Broadcast("^5IW4MAdmin ^7is going ^1offline^7");
|
||||
S.isRunning = false;
|
||||
|
||||
if (Utilities.shutdownInterface(S.pID()))
|
||||
@ -77,14 +78,13 @@ namespace IW4MAdmin
|
||||
Program.getManager().shutDown();
|
||||
frontEnd.webSchedule.Stop();
|
||||
frontEnd.webSchedule.Dispose();
|
||||
return false;
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private delegate bool ConsoleEventDelegate(int eventType);
|
||||
|
@ -216,7 +216,8 @@ namespace IW4MAdmin
|
||||
return null;
|
||||
}
|
||||
|
||||
SharedLibrary.Utilities.Wait(2);
|
||||
if (timeWaiting > 5)
|
||||
SharedLibrary.Utilities.Wait(2);
|
||||
|
||||
dvar net_ip = Utilities.getDvarOld(0x64A1DF8, (int)Handle);
|
||||
dvar net_port = Utilities.getDvarOld(0x64A3004, (int)Handle);
|
||||
|
@ -8,17 +8,17 @@ namespace IW4MAdmin
|
||||
{
|
||||
public class PluginImporter
|
||||
{
|
||||
public static List<Command> potentialPlugins = new List<Command>();
|
||||
public static List<EventNotify> potentialNotifies = new List<EventNotify>();
|
||||
public static List<Command> potentialCommands;
|
||||
public static List<EventNotify> potentialNotifies;
|
||||
|
||||
public static bool Load()
|
||||
{
|
||||
string[] dllFileNames = null;
|
||||
potentialCommands = new List<Command>();
|
||||
potentialNotifies = new List<EventNotify>();
|
||||
|
||||
if (Directory.Exists(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\plugins"))
|
||||
{
|
||||
dllFileNames = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\plugins", "*.dll");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
@ -52,6 +52,7 @@ namespace IW4MAdmin
|
||||
Object notifyObject = Activator.CreateInstance(assemblyType);
|
||||
EventNotify newNotify = (EventNotify)notifyObject;
|
||||
potentialNotifies.Add(newNotify);
|
||||
newNotify.onLoad();
|
||||
Program.getManager().mainLog.Write("Loaded event plugin \"" + assemblyType.Name + "\"", Log.Level.All);
|
||||
}
|
||||
|
||||
@ -59,7 +60,7 @@ namespace IW4MAdmin
|
||||
{
|
||||
Object commandObject = Activator.CreateInstance(assemblyType);
|
||||
Command newCommand = (Command)commandObject;
|
||||
potentialPlugins.Add(newCommand);
|
||||
potentialCommands.Add(newCommand);
|
||||
Program.getManager().mainLog.Write("Loaded command plugin \"" + newCommand.Name + "\"", Log.Level.All);
|
||||
}
|
||||
|
||||
|
@ -83,12 +83,9 @@ namespace IW4MAdmin
|
||||
clientDB.addPlayer(P);
|
||||
NewPlayer = clientDB.getPlayer(P.npID, P.clientID);
|
||||
aliasDB.addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP));
|
||||
statDB.addPlayer(NewPlayer);
|
||||
}
|
||||
|
||||
NewPlayer.updateName(P.Name.Trim());
|
||||
|
||||
NewPlayer.stats = statDB.getStats(NewPlayer.databaseID);
|
||||
NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.databaseID);
|
||||
|
||||
if (NewPlayer.Alias == null)
|
||||
@ -204,12 +201,6 @@ namespace IW4MAdmin
|
||||
if (NewPlayer.Level > Player.Permission.Moderator)
|
||||
NewPlayer.Tell("There are ^5" + Reports.Count + " ^7recent reports!");
|
||||
|
||||
if (NewPlayer.stats == null) // there seems to be an issue with stats with multiple servers. I think this should fix it
|
||||
{
|
||||
statDB.addPlayer(NewPlayer);
|
||||
NewPlayer.stats = statDB.getStats(NewPlayer.databaseID);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#if DEBUG == false
|
||||
@ -235,7 +226,6 @@ namespace IW4MAdmin
|
||||
Player Leaving = players[cNum];
|
||||
Leaving.Connections++;
|
||||
clientDB.updatePlayer(Leaving);
|
||||
statDB.updatePlayer(Leaving);
|
||||
|
||||
Log.Write("Client at " + cNum + " disconnecting...", Log.Level.Debug);
|
||||
events.Enqueue(new Event(Event.GType.Disconnect, "", Leaving, null, this));
|
||||
@ -674,27 +664,9 @@ namespace IW4MAdmin
|
||||
return false;
|
||||
}
|
||||
|
||||
if (E.Target == null)
|
||||
{
|
||||
Log.Write("Kill event triggered, but no target found!", Log.Level.Debug);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (E.Origin.stats == null)
|
||||
{
|
||||
Log.Write("Kill event triggered, but no stats found for origin!", Log.Level.Debug);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (E.Target.stats == null)
|
||||
{
|
||||
Log.Write("Kill event triggered, but no stats found for target!", Log.Level.Debug);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (E.Origin != E.Target)
|
||||
{
|
||||
E.Origin.stats.Kills += 1;
|
||||
/*E.Origin.stats.Kills += 1;
|
||||
E.Origin.stats.updateKDR();
|
||||
|
||||
E.Target.stats.Deaths += 1;
|
||||
@ -704,17 +676,15 @@ namespace IW4MAdmin
|
||||
statDB.updatePlayer(E.Origin);
|
||||
statDB.updatePlayer(E.Target);
|
||||
|
||||
totalKills++;
|
||||
totalKills++;*/
|
||||
Log.Write(E.Origin.Name + " killed " + E.Target.Name + " with a " + E.Data, Log.Level.Debug);
|
||||
events.Enqueue(new Event(Event.GType.Death, E.Data, E.Target, null, this));
|
||||
}
|
||||
|
||||
else // suicide/falling
|
||||
{
|
||||
E.Origin.stats.Deaths++;
|
||||
E.Origin.stats.updateKDR();
|
||||
statDB.updatePlayer(E.Origin);
|
||||
Log.Write(E.Origin.Name + " suicided...", Log.Level.Debug);
|
||||
events.Enqueue(new Event(Event.GType.Death, "suicide", E.Target, null, this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -820,13 +790,6 @@ namespace IW4MAdmin
|
||||
if (E.Type == Event.GType.MapEnd)
|
||||
{
|
||||
Log.Write("Game ending...", Log.Level.Debug);
|
||||
foreach (Player P in players)
|
||||
{
|
||||
if (P == null || P.stats == null)
|
||||
continue;
|
||||
statDB.updatePlayer(P);
|
||||
Log.Write("Updated stats for client " + P.databaseID, Log.Level.Debug);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -846,8 +809,8 @@ namespace IW4MAdmin
|
||||
clientDB.addBan(newBan);
|
||||
clientDB.updatePlayer(Target);
|
||||
|
||||
// foreach (SharedLibrary.Server S in Program.getServers()) // make sure bans show up on the webfront
|
||||
// S.Bans = S.clientDB.getBans();
|
||||
foreach (SharedLibrary.Server S in Program.getServers()) // make sure bans show up on the webfront
|
||||
S.Bans = S.clientDB.getBans();
|
||||
|
||||
lock (Reports) // threading seems to do something weird here
|
||||
{
|
||||
@ -879,12 +842,37 @@ namespace IW4MAdmin
|
||||
P.setLevel(Player.Permission.User);
|
||||
clientDB.updatePlayer(P);
|
||||
|
||||
foreach (SharedLibrary.Server S in Program.getServers()) // make sure bans show up on the webfront
|
||||
S.Bans = S.clientDB.getBans();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public bool Reload()
|
||||
{
|
||||
try
|
||||
{
|
||||
messages = null;
|
||||
maps = null;
|
||||
rules = null;
|
||||
initMaps();
|
||||
initMessages();
|
||||
initRules();
|
||||
PluginImporter.Load();
|
||||
return true;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
Log.Write("Unable to reload configs! - " + E.Message, Log.Level.Debug);
|
||||
messages = new List<String>();
|
||||
maps = new List<Map>();
|
||||
rules = new List<String>();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
override public void initMacros()
|
||||
{
|
||||
@ -923,8 +911,8 @@ namespace IW4MAdmin
|
||||
commands.Add(new Find("find", "find player in database. syntax: !find <player>", "f", Player.Permission.SeniorAdmin, 1, false));
|
||||
commands.Add(new Rules("rules", "list server rules. syntax: !rules", "r", Player.Permission.User, 0, false));
|
||||
commands.Add(new PrivateMessage("privatemessage", "send message to other player. syntax: !pm <player> <message>", "pm", Player.Permission.User, 2, true));
|
||||
commands.Add(new _Stats("stats", "view your stats or another player's. syntax: !stats", "xlrstats", Player.Permission.User, 0, true));
|
||||
commands.Add(new TopStats("topstats", "view the top 4 players on this server. syntax: !topstats", "xlrtopstats", Player.Permission.User, 0, false));
|
||||
//commands.Add(new _Stats("stats", "view your stats or another player's. syntax: !stats", "xlrstats", Player.Permission.User, 0, true));
|
||||
//commands.Add(new TopStats("topstats", "view the top 4 players on this server. syntax: !topstats", "xlrtopstats", Player.Permission.User, 0, false));
|
||||
commands.Add(new Reload("reload", "reload configurations. syntax: !reload", "reload", Player.Permission.Owner, 0, false));
|
||||
commands.Add(new Balance("balance", "balance teams. syntax !balance", "bal", Player.Permission.Moderator, 0, false));
|
||||
commands.Add(new GoTo("goto", "teleport to selected player. syntax !goto", "go", Player.Permission.SeniorAdmin, 1, true));
|
||||
@ -938,7 +926,7 @@ namespace IW4MAdmin
|
||||
commands.Add(new _RCON("rcon", "send rcon command to server. syntax: !rcon <command>", "rcon", Player.Permission.Owner, 1, false));
|
||||
commands.Add(new FindAll("findall", "find a player by their aliase(s). syntax: !findall <player>", "fa", Player.Permission.Moderator, 1, false));
|
||||
|
||||
foreach (Command C in PluginImporter.potentialPlugins)
|
||||
foreach (Command C in PluginImporter.potentialCommands)
|
||||
commands.Add(C);
|
||||
|
||||
}
|
||||
|
@ -367,21 +367,16 @@ namespace IW4MAdmin
|
||||
return false;
|
||||
}
|
||||
|
||||
//ClientId clientid = new ClientId();
|
||||
//threadID = new IntPtr();
|
||||
uint ThreadID2;
|
||||
threadID = IntPtr.Zero;
|
||||
//RtlCreateUserThread(ProcessHandle, IntPtr.Zero, false, 0, (uint)0, IntPtr.Zero, lpLLAddress, baseAddress, out threadID, out clientid);
|
||||
//SCreateRemoteThread(ProcessHandle, IntPtr.Zero, 0, lpLLAddress, baseAddress, 0, out ThreadID2);
|
||||
return true;
|
||||
ClientId clientid = new ClientId();
|
||||
threadID = new IntPtr();
|
||||
|
||||
RtlCreateUserThread(ProcessHandle, IntPtr.Zero, false, 0, (uint)0, IntPtr.Zero, lpLLAddress, baseAddress, out threadID, out clientid);
|
||||
if (threadID == IntPtr.Zero)
|
||||
{
|
||||
Program.getManager().mainLog.Write("Could not create remote thread");
|
||||
return false;
|
||||
}
|
||||
#if DEBUG
|
||||
//Program.getManager().mainLog.Write("Thread Status is " + threadStatus);
|
||||
Program.getManager().mainLog.Write("Thread ID is " + threadID);
|
||||
#endif
|
||||
uint responseCode = WaitForSingleObject(threadID, 3000);
|
||||
@ -399,8 +394,8 @@ namespace IW4MAdmin
|
||||
{
|
||||
if (Pointer != IntPtr.Zero)
|
||||
{
|
||||
// if (!VirtualFreeEx(ProcessHandle, Pointer, 0, AllocationType.Release))
|
||||
// Program.getManager().mainLog.Write("Virtual Free Failed During Exit Cleanup -- Error #" + Marshal.GetLastWin32Error());
|
||||
if (!VirtualFreeEx(ProcessHandle, Pointer, 0, AllocationType.Release))
|
||||
Program.getManager().mainLog.Write("Virtual Free Failed During Exit Cleanup -- Error #" + Marshal.GetLastWin32Error());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ namespace IW4MAdmin_Web
|
||||
buffer.Append("<div id=pages>");
|
||||
return buffer.ToString();
|
||||
case "STATS":
|
||||
int totalStats = Servers[server].statDB.totalStats();
|
||||
int totalStats = 0;
|
||||
buffer.Append("<h1 style='margin-top: 0;'>Starting at #{{TOP}}</h1><hr />");
|
||||
buffer.Append("<table style='width:100%' cellspacing=0 class=stats>");
|
||||
|
||||
@ -239,10 +239,10 @@ namespace IW4MAdmin_Web
|
||||
range = (totalStats - start);
|
||||
else
|
||||
range = 30;
|
||||
List<Stats> Stats = Servers[server].statDB.getMultipleStats(start, range).OrderByDescending(x => x.Skill).ToList();
|
||||
//List<Stats> Stats = Servers[server].statDB.getMultipleStats(start, range).OrderByDescending(x => x.Skill).ToList();
|
||||
buffer.Append("<tr><th style=text-align:left;>Name</th><th style=text-align:left;>Kills</th><th style=text-align:left;>Deaths</th><th style=text-align:left;>KDR</th><th style='width: 175px; text-align:right;'>Rating</th></tr>");
|
||||
cycleFix = 0;
|
||||
for (int i = 0; i < totalStats; i++)
|
||||
/*for (int i = 0; i < totalStats; i++)
|
||||
{
|
||||
if (i >= Stats.Count -1 || Stats[i] == null )
|
||||
continue;
|
||||
@ -267,7 +267,7 @@ namespace IW4MAdmin_Web
|
||||
buffer.AppendFormat("<tr {5}><td><a href='{6}'>{0}</a></td><td style='border-left: 3px solid #bbb; text-align:left;'>{1}</td><td style='border-left: 3px solid #bbb;text-align:left;'>{2}</td><td style='border-left: 3px solid #bbb;text-align:left;'>{3}</td><td style='width: 175px; text-align:right;'>{4}</td></tr></div>", P.Name, P.stats.Kills, P.stats.Deaths, P.stats.KDR, P.stats.Skill, Prefix, Link);
|
||||
cycleFix++;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
buffer.Append("</table><hr/>");
|
||||
buffer.Append(parsePagination(server, totalStats, 30, Pagination, "stats"));
|
||||
return buffer.ToString().Replace("{{TOP}}", (start + 1).ToString());
|
||||
@ -327,14 +327,6 @@ namespace IW4MAdmin_Web
|
||||
str.AppendFormat("<span>{0}</span><br/>", a.Name);
|
||||
}
|
||||
|
||||
Player.stats = Servers[server].statDB.getStats(Player.databaseID);
|
||||
String Rating = String.Empty;
|
||||
|
||||
if (Player.stats == null)
|
||||
Rating = "Not Available";
|
||||
else
|
||||
Rating = Player.stats.Skill.ToString();
|
||||
|
||||
StringBuilder IPs = new StringBuilder();
|
||||
|
||||
if (logged)
|
||||
@ -364,7 +356,7 @@ namespace IW4MAdmin_Web
|
||||
if (logged)
|
||||
Screenshot = String.Format("<a href='http://server.nbsclan.org/screen.php?id={0}&name={1}'><div style='background-image:url(http://server.nbsclan.org/shutter.png); width: 20px; height: 20px;float: right; position:relative; right: 21%; background-size: contain;'></div></a>", forumID, Player.Name);
|
||||
|
||||
buffer.AppendFormat("<td><a style='float: left;' href='{9}'>{0}</a>{10}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6} ago</td><td><a href='https://repziw4.de/memberlist.php?mode=viewprofile&u={7}'>{8}</a></td>", Player.Name, str, IPs, Rating, SharedLibrary.Utilities.nameHTMLFormatted(Player), Player.Connections, Player.getLastConnection(), forumID, Player.Name, "/0/" + Player.databaseID + "/userip/?player", Screenshot);
|
||||
buffer.AppendFormat("<td><a style='float: left;' href='{9}'>{0}</a>{10}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6} ago</td><td><a href='https://repziw4.de/memberlist.php?mode=viewprofile&u={7}'>{8}</a></td>", Player.Name, str, IPs, 0, SharedLibrary.Utilities.nameHTMLFormatted(Player), Player.Connections, Player.getLastConnection(), forumID, Player.Name, "/0/" + Player.databaseID + "/userip/?player", Screenshot);
|
||||
buffer.Append("</tr>");
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user