fixed another issue with config creation

fixed issue with player count
added topstats command
This commit is contained in:
RaidMax 2015-03-10 16:56:01 -05:00
parent 57ddbebd8c
commit 74312d5b4e
9 changed files with 76 additions and 15 deletions

View File

@ -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<Stats> Top = E.Owner.stats.topStats();
List<Player> TopP = new List<Player>();
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!");
}
}
} }

View File

@ -29,7 +29,7 @@ namespace IW4MAdmin
return result; return result;
} }
catch (System.Net.WebException E) catch (System.Net.WebException)
{ {
return null; return null;
} }
@ -43,7 +43,7 @@ namespace IW4MAdmin
Resp.Close(); Resp.Close();
} }
catch (System.Net.WebException E) catch (System.Net.WebException)
{ {
return; return;
} }

View File

@ -168,6 +168,25 @@ namespace IW4MAdmin
} }
} }
public List<Stats> topStats()
{
String Query = String.Format("SELECT * FROM STATS WHERE SKILL > '{0}' LIMIT 4", 20);
DataTable Result = GetDataTable(Query);
List<Stats> Top = new List<Stats>();
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) public void updatePlayer(Player P)
{ {
Dictionary<String, object> updatedPlayer = new Dictionary<String, object>(); Dictionary<String, object> updatedPlayer = new Dictionary<String, object>();

View File

@ -28,7 +28,7 @@ namespace IW4MAdmin
public file(String file, bool write) public file(String file, bool write)
{ {
Name = file; 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; sze = 0;
} }

View File

@ -28,14 +28,14 @@
<PublisherName>RaidMax LLC</PublisherName> <PublisherName>RaidMax LLC</PublisherName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage> <WebPage>publish.htm</WebPage>
<ApplicationRevision>4</ApplicationRevision> <ApplicationRevision>5</ApplicationRevision>
<ApplicationVersion>0.2.0.%2a</ApplicationVersion> <ApplicationVersion>0.3.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -148,6 +148,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy $(TargetDir)$(TargetFileName) $(SolutionDir)OFFICIAL\NBS\$(TargetFileName)</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

View File

@ -10,7 +10,7 @@ namespace IW4MAdmin
static String IP; static String IP;
static int Port; static int Port;
static String RCON; static String RCON;
static public double Version = 0.2; static public double Version = 0.3;
static public double latestVersion; static public double latestVersion;
static void Main(string[] args) static void Main(string[] args)
@ -73,12 +73,15 @@ namespace IW4MAdmin
file Config = new file("config\\servers.cfg"); file Config = new file("config\\servers.cfg");
String[] SV_CONF = Config.readAll(); String[] SV_CONF = Config.readAll();
List<Server> Servers = new List<Server>(); List<Server> Servers = new List<Server>();
Config.Close();
if (SV_CONF == null || SV_CONF.Length < 1 || SV_CONF[0] == String.Empty) if (SV_CONF == null || SV_CONF.Length < 1 || SV_CONF[0] == String.Empty)
{ {
setupConfig(); // get our first time server setupConfig(); // get our first time server
Config = new file("config\\servers.cfg", true);
Config.Write(IP + ':' + Port + ':' + RCON); Config.Write(IP + ':' + Port + ':' + RCON);
Config.Close();
Servers.Add(new Server(IP, Port, RCON)); Servers.Add(new Server(IP, Port, RCON));
} }

View File

@ -134,7 +134,6 @@ namespace IW4MAdmin
private UdpClient sv_connection; private UdpClient sv_connection;
private Server Instance; private Server Instance;
private DateTime lastCMD;
private Queue<String> toSend; private Queue<String> toSend;
} }
} }

View File

@ -112,11 +112,13 @@ namespace IW4MAdmin
stats.addPlayer(P); stats.addPlayer(P);
P.stats = new Stats(0, 0, 0, 0); P.stats = new Stats(0, 0, 0, 0);
} }
if(players[P.getClientNum()] == null)
clientnum++;
players[P.getClientNum()] = null; players[P.getClientNum()] = null;
players[P.getClientNum()] = P; players[P.getClientNum()] = P;
clientnum++;
if (P.getLevel() == Player.Permission.Banned) if (P.getLevel() == Player.Permission.Banned)
{ {
Log.Write("Banned client " + P.getName() + " trying to connect...", Log.Level.Debug); Log.Write("Banned client " + P.getName() + " trying to connect...", Log.Level.Debug);
@ -293,8 +295,8 @@ namespace IW4MAdmin
String[] oldLines = new String[8]; String[] oldLines = new String[8];
DateTime start = DateTime.Now; DateTime start = DateTime.Now;
//Utilities.Wait(1); Utilities.Wait(1);
//Broadcast("IW4M Admin is now ^2ONLINE"); Broadcast("IW4M Admin is now ^2ONLINE");
while (errors <=5) while (errors <=5)
{ {
@ -787,6 +789,7 @@ namespace IW4MAdmin
commands.Add(new Rules("rules", "list server rules. syntax: !rules", "r", Player.Permission.User, 0, 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 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 _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 commands { command = "stats", desc = "view your server stats.", requiredPer = 0 }); commands.Add(new commands { command = "stats", desc = "view your server stats.", requiredPer = 0 });
commands.Add(new commands { command = "speed", desc = "change player speed. syntax: !speed <number>", requiredPer = 3 }); commands.Add(new commands { command = "speed", desc = "change player speed. syntax: !speed <number>", requiredPer = 3 });
@ -821,7 +824,7 @@ namespace IW4MAdmin
private TimeSpan lastMessage; private TimeSpan lastMessage;
private int nextMessage; private int nextMessage;
private int errors = 0; private int errors = 0;
private Connection Heartbeat;
//Log stuff //Log stuff
private String Basepath; private String Basepath;

View File

@ -11,8 +11,8 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|Any CPU.ActiveCfg = Release|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|Any CPU.Build.0 = Release|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|Any CPU.Build.0 = Release|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection