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;
}
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;
}

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)
{
Dictionary<String, object> updatedPlayer = new Dictionary<String, object>();

View File

@ -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;
}

View File

@ -28,14 +28,14 @@
<PublisherName>RaidMax LLC</PublisherName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>4</ApplicationRevision>
<ApplicationVersion>0.2.0.%2a</ApplicationVersion>
<ApplicationRevision>5</ApplicationRevision>
<ApplicationVersion>0.3.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@ -148,6 +148,9 @@
</ItemGroup>
<ItemGroup />
<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.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

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

View File

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

View File

@ -112,11 +112,13 @@ namespace IW4MAdmin
stats.addPlayer(P);
P.stats = new Stats(0, 0, 0, 0);
}
if(players[P.getClientNum()] == null)
clientnum++;
players[P.getClientNum()] = null;
players[P.getClientNum()] = P;
clientnum++;
if (P.getLevel() == Player.Permission.Banned)
{
Log.Write("Banned client " + P.getName() + " trying to connect...", Log.Level.Debug);
@ -293,8 +295,8 @@ namespace IW4MAdmin
String[] oldLines = new String[8];
DateTime start = DateTime.Now;
//Utilities.Wait(1);
//Broadcast("IW4M Admin is now ^2ONLINE");
Utilities.Wait(1);
Broadcast("IW4M Admin is now ^2ONLINE");
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 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 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 });
@ -821,7 +824,7 @@ namespace IW4MAdmin
private TimeSpan lastMessage;
private int nextMessage;
private int errors = 0;
private Connection Heartbeat;
//Log stuff
private String Basepath;

View File

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