From 74312d5b4ea09adc0ebbe29a39e99d1b6166f33b Mon Sep 17 00:00:00 2001 From: RaidMax Date: Tue, 10 Mar 2015 16:56:01 -0500 Subject: [PATCH] fixed another issue with config creation fixed issue with player count added topstats command --- Admin/Command.cs | 34 ++++++++++++++++++++++++++++++++++ Admin/Connection.cs | 4 ++-- Admin/Database.cs | 19 +++++++++++++++++++ Admin/File.cs | 2 +- Admin/IW4M ADMIN.csproj | 9 ++++++--- Admin/Main.cs | 5 ++++- Admin/RCON.cs | 1 - Admin/Server.cs | 13 ++++++++----- IW4M Admin.sln | 4 ++-- 9 files changed, 76 insertions(+), 15 deletions(-) diff --git a/Admin/Command.cs b/Admin/Command.cs index 9fac290e..a712a4da 100644 --- a/Admin/Command.cs +++ b/Admin/Command.cs @@ -460,4 +460,38 @@ namespace IW4MAdmin } } + 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 Top = E.Owner.stats.topStats(); + List TopP = new List(); + + foreach (Stats S in Top) + { + Player P = E.Owner.DB.findPlayers(S.Kills); // BAD + if (P != null) + { + 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.getName(), P.stats.KDR, P.stats.Skill)); + + } + } + else + E.Origin.Tell("There are no top players yet!"); + } + } + + } diff --git a/Admin/Connection.cs b/Admin/Connection.cs index f970f446..6cd4577c 100644 --- a/Admin/Connection.cs +++ b/Admin/Connection.cs @@ -29,7 +29,7 @@ namespace IW4MAdmin return result; } - catch (System.Net.WebException E) + catch (System.Net.WebException) { return null; } @@ -43,7 +43,7 @@ namespace IW4MAdmin Resp.Close(); } - catch (System.Net.WebException E) + catch (System.Net.WebException) { return; } diff --git a/Admin/Database.cs b/Admin/Database.cs index e1c0cd6c..c6407bc5 100644 --- a/Admin/Database.cs +++ b/Admin/Database.cs @@ -168,6 +168,25 @@ namespace IW4MAdmin } } + public List topStats() + { + String Query = String.Format("SELECT * FROM STATS WHERE SKILL > '{0}' LIMIT 4", 20); + DataTable Result = GetDataTable(Query); + + List Top = new List(); + + if (Result != null && Result.Rows.Count > 0) + { + foreach (DataRow D in Result.Rows) + { + Stats S = new Stats(Convert.ToInt32(D["Number"]), Convert.ToInt32(D["DEATHS"]), Convert.ToDouble(D["KDR"]), Convert.ToDouble(D["SKILL"])); + Top.Add(S); + } + } + + return Top; + } + public void updatePlayer(Player P) { Dictionary updatedPlayer = new Dictionary(); diff --git a/Admin/File.cs b/Admin/File.cs index c4cd735c..dfd3d13b 100644 --- a/Admin/File.cs +++ b/Admin/File.cs @@ -28,7 +28,7 @@ namespace IW4MAdmin public file(String file, bool write) { Name = file; - writeHandle = new StreamWriter(new FileStream(Name, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)); + writeHandle = new StreamWriter(new FileStream(Name, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)); sze = 0; } diff --git a/Admin/IW4M ADMIN.csproj b/Admin/IW4M ADMIN.csproj index 4a817a6e..c4777c8f 100644 --- a/Admin/IW4M ADMIN.csproj +++ b/Admin/IW4M ADMIN.csproj @@ -28,14 +28,14 @@ RaidMax LLC true publish.htm - 4 - 0.2.0.%2a + 5 + 0.3.0.%2a false true true - AnyCPU + x86 true full false @@ -148,6 +148,9 @@ + + copy $(TargetDir)$(TargetFileName) $(SolutionDir)OFFICIAL\NBS\$(TargetFileName) +