Various fixes and renamed 'libary' to 'library'

This commit is contained in:
RaidMax 2015-08-27 23:39:36 -05:00
parent c23e578319
commit 995334796e
31 changed files with 146 additions and 129 deletions

View File

@ -108,7 +108,7 @@ namespace IW4MAdmin
if (E.Owner.Website == null) if (E.Owner.Website == null)
Message = "^1Player Banned: ^5" + E.Target.lastOffense; Message = "^1Player Banned: ^5" + E.Target.lastOffense;
else else
Message = "^1Player Banned: ^5" + E.Target.lastOffense + "^7 (appeal " + E.Owner.Website; Message = "^1Player Banned: ^5" + E.Target.lastOffense + "^7 (appeal at" + E.Owner.Website + ")";
if (E.Origin.Level > E.Target.Level) if (E.Origin.Level > E.Target.Level)
{ {
E.Target.Ban(Message, E.Origin); E.Target.Ban(Message, E.Origin);

View File

@ -88,9 +88,9 @@
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="SharedLibary"> <Reference Include="SharedLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\SharedLibary\SharedLibary\bin\Debug\SharedLibary.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<Private>False</Private> <HintPath>lib\SharedLibrary.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" /> <Reference Include="System.ComponentModel.Composition" />
@ -132,7 +132,7 @@
<Content Include="lib\AdminInterface.dll"> <Content Include="lib\AdminInterface.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="lib\SharedLibary.dll"> <Content Include="lib\SharedLibrary.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="lib\SQLite.Interop.dll"> <Content Include="lib\SQLite.Interop.dll">
@ -307,7 +307,7 @@ del *.dll
del app.config del app.config
del *.manifest del *.manifest
del *.log del *.log
xcopy /E /Y "$(ProjectDir)bin\Release" "$(SolutionDir)Release Build"</PostBuildEvent> xcopy /Y /I /E "*" "$(SolutionDir)Release Build"</PostBuildEvent>
</PropertyGroup> </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.

View File

@ -125,27 +125,24 @@ namespace IW4MAdmin
if (pID == 0) if (pID == 0)
continue; continue;
bool newProcess = true; if (activePIDs.IndexOf(pID) == -1 && !ThreadList.ContainsKey(pID))
foreach (int I in activePIDs)
{ {
if (I == pID)
newProcess = false;
}
if (newProcess) Server S = loadIndividualServer(pID);
{
if (!ThreadList.ContainsKey(pID)) if (S == null)
{ {
Server S = loadIndividualServer(pID); mainLog.Write("Unable to load new detected server!", Log.Level.Debug);
Servers.Add(S); continue;
Thread IW4MServerThread = new Thread(S.Monitor);
ThreadList.Add(pID, IW4MServerThread);
mainLog.Write("New server detected on port " + S.getPort(), Log.Level.Production);
IW4MServerThread.Start();
} }
Servers.Add(S);
Thread IW4MServerThread = new Thread(S.Monitor);
ThreadList.Add(pID, IW4MServerThread);
mainLog.Write("New server detected on port " + S.getPort(), Log.Level.Production);
IW4MServerThread.Start();
} }
} }
} }
private bool isIW4MStillRunning(int pID) private bool isIW4MStillRunning(int pID)

View File

@ -84,8 +84,6 @@ namespace IW4MAdmin
NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.databaseID); NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.databaseID);
} }
// try not to crash if no stats!
if (P.lastEvent == null || P.lastEvent.Owner == null) if (P.lastEvent == null || P.lastEvent.Owner == null)
NewPlayer.lastEvent = new Event(Event.GType.Say, null, NewPlayer, null, this); // this is messy but its throwing an error when they've started it too late NewPlayer.lastEvent = new Event(Event.GType.Say, null, NewPlayer, null, this); // this is messy but its throwing an error when they've started it too late
else else
@ -299,7 +297,7 @@ namespace IW4MAdmin
return null; return null;
} }
//Procses requested command correlating to an event //Process requested command correlating to an event
override public Command processCommand(Event E, Command C) override public Command processCommand(Event E, Command C)
{ {
E.Data = SharedLibrary.Utilities.removeWords(E.Data, 1); E.Data = SharedLibrary.Utilities.removeWords(E.Data, 1);
@ -392,7 +390,10 @@ namespace IW4MAdmin
Event curEvent = events.Peek(); Event curEvent = events.Peek();
if (curEvent == null) if (curEvent == null)
{
events.Dequeue();
continue; continue;
}
processEvent(curEvent); processEvent(curEvent);
foreach (Plugin P in PluginImporter.potentialPlugins) foreach (Plugin P in PluginImporter.potentialPlugins)
@ -404,12 +405,11 @@ namespace IW4MAdmin
catch (Exception Except) catch (Exception Except)
{ {
Log.Write(String.Format("The plugin \"{0}\" (v{1}) generated an error. ( see log )", P.Name, P.Version), Log.Level.Production); Log.Write(String.Format("The plugin \"{0}\" generated an error. ( see log )", P.Name), Log.Level.Production);
Log.Write(String.Format("Error Message: {0}", Except.Message), Log.Level.Debug); Log.Write(String.Format("Error Message: {0}", Except.Message), Log.Level.Debug);
Log.Write(String.Format("Error Trace: {0}", Except.StackTrace), Log.Level.Debug); Log.Write(String.Format("Error Trace: {0}", Except.StackTrace), Log.Level.Debug);
continue; continue;
} }
} }
events.Dequeue(); events.Dequeue();
} }
@ -622,6 +622,10 @@ namespace IW4MAdmin
// our settings // our settings
setDvar("sv_kickbantime", "3600"); // 1 hour setDvar("sv_kickbantime", "3600"); // 1 hour
Website = getDvar("_website").current;
if (Website == "0" || Website == null)
Website = "this server's website";
int logSync = -1; int logSync = -1;
Int32.TryParse(getDvar("g_logSync").current, out oneLog); Int32.TryParse(getDvar("g_logSync").current, out oneLog);
@ -910,7 +914,6 @@ namespace IW4MAdmin
// Something like *COMMAND* | NAME | HELP MSG | ALIAS | NEEDED PERMISSION | # OF REQUIRED ARGS | HAS TARGET | // Something like *COMMAND* | NAME | HELP MSG | ALIAS | NEEDED PERMISSION | # OF REQUIRED ARGS | HAS TARGET |
commands = new List<Command>(); commands = new List<Command>();
owner = clientDB.getOwner(); owner = clientDB.getOwner();
if(owner == null) if(owner == null)

View File

@ -344,8 +344,19 @@ namespace IW4MAdmin
} }
List<IntPtr> baseAddresses = new List<IntPtr>(); List<IntPtr> baseAddresses = new List<IntPtr>();
System.Diagnostics.Process P;
try
{
P = System.Diagnostics.Process.GetProcessById(pID);
}
catch (System.ArgumentException)
{
Program.getManager().mainLog.Write("The server with PID " + pID + " was exited before deinit occured.", Log.Level.Debug);
return false;
}
System.Diagnostics.Process P = System.Diagnostics.Process.GetProcessById(pID);
foreach (System.Diagnostics.ProcessModule M in P.Modules) foreach (System.Diagnostics.ProcessModule M in P.Modules)
{ {
if (M.ModuleName == "AdminInterface.dll" && M.BaseAddress != IntPtr.Zero) if (M.ModuleName == "AdminInterface.dll" && M.BaseAddress != IntPtr.Zero)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 2013
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IW4M ADMIN", "Admin\IW4M ADMIN.csproj", "{DD5DCDA2-51DB-4B1A-922F-5705546E6115}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IW4M ADMIN", "Admin\IW4M ADMIN.csproj", "{DD5DCDA2-51DB-4B1A-922F-5705546E6115}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
@ -10,11 +10,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IW4M ADMIN", "Admin\IW4M AD
{D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6} {D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedLibrary", "SharedLibary\SharedLibrary.csproj", "{D51EECEB-438A-47DA-870F-7D7B41BC24D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webfront Plugin", "Webfront Plugin\Webfront Plugin.csproj", "{99E36EBD-1FA1-494C-8A66-BECE64EFF378}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Webfront Plugin", "Webfront Plugin\Webfront Plugin.csproj", "{99E36EBD-1FA1-494C-8A66-BECE64EFF378}"
ProjectSection(ProjectDependencies) = postProject
{D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6}
EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stats Plugin", "Stats Plugin\Stats Plugin.csproj", "{4785AB75-66F3-4391-985D-63A5A049A0FA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stats Plugin", "Stats Plugin\Stats Plugin.csproj", "{4785AB75-66F3-4391-985D-63A5A049A0FA}"
ProjectSection(ProjectDependencies) = postProject
{D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedLibrary", "SharedLibrary\SharedLibrary.csproj", "{D51EECEB-438A-47DA-870F-7D7B41BC24D6}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -24,20 +30,20 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|Any CPU.ActiveCfg = Debug|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}.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 = Debug|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 = Debug|Any CPU
{99E36EBD-1FA1-494C-8A66-BECE64EFF378}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99E36EBD-1FA1-494C-8A66-BECE64EFF378}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99E36EBD-1FA1-494C-8A66-BECE64EFF378}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{99E36EBD-1FA1-494C-8A66-BECE64EFF378}.Release|Any CPU.Build.0 = Debug|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|Any CPU.Build.0 = Debug|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Any CPU.Build.0 = Debug|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|Any CPU.ActiveCfg = Release|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|Any CPU.Build.0 = Release|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|Any CPU.Build.0 = Release|Any CPU
{99E36EBD-1FA1-494C-8A66-BECE64EFF378}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99E36EBD-1FA1-494C-8A66-BECE64EFF378}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99E36EBD-1FA1-494C-8A66-BECE64EFF378}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99E36EBD-1FA1-494C-8A66-BECE64EFF378}.Release|Any CPU.Build.0 = Release|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Binary file not shown.

View File

@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("SharedLibary")] [assembly: AssemblyTitle("SharedLibrary")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SharedLibary")] [assembly: AssemblyProduct("SharedLibrary")]
[assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]

View File

@ -8,7 +8,7 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharedLibrary</RootNamespace> <RootNamespace>SharedLibrary</RootNamespace>
<AssemblyName>SharedLibary</AssemblyName> <AssemblyName>SharedLibrary</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
@ -65,7 +65,7 @@
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\lib\$(TargetName).dll"</PostBuildEvent> <PostBuildEvent>copy /Y "$(TargetDir)$(TargetFileName)" "$(SolutionDir)Admin\lib\SharedLibrary.dll"</PostBuildEvent>
</PropertyGroup> </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.

View File

@ -5,66 +5,8 @@ using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
namespace SamplePlugin namespace StatsPlugin
{ {
#if SAMPLE_CODE
public class SampleCommand : Command
{
public SampleCommand() : base("testplugin", "sample plugin command. syntax !testplugin", "tp", Player.Permission.User, 0, false) { }
public override void Execute(Event E)
{
Player clientWhoSent = E.Origin;
Server originatingServer = E.Owner;
String[] messageToClient = {
String.Format("The command {0} was requested by ^3{1}", Name, clientWhoSent.Name),
String.Format("The command was request on server ^1{0}", originatingServer.getName())
};
foreach (String Line in messageToClient)
clientWhoSent.Tell(Line);
}
}
public class AnotherSampleCommand : Command
{
public AnotherSampleCommand() : base("scream", "broadcast your message. syntax !scream <message>", "s", Player.Permission.Moderator, 1, false) { }
public override void Execute(Event E)
{
Server originatingServer = E.Owner;
String Message = E.Data;
String Sender = E.Origin.Name;
for (int i = 0; i < 10; i++)
originatingServer.Broadcast(String.Format("^7{0}: ^{1}{2}^7", Sender, i, Message));
originatingServer.Log.Write("This line is coming from the plugin " + this.Name, Log.Level.Production);
}
}
public class SampleEvent : EventNotify
{
public override void onLoad()
{
Console.WriteLine("The sample event plugin was loaded!");
}
public override void onEvent(Event E)
{
E.Owner.Broadcast("An event occured of type: ^1" + E.Type);
if (E.Data != null)
E.Origin.Tell(E.Data);
}
}
public class InvalidCommandExample
{
private void doNotDoThis() { }
}
#endif
public class StatCommand : Command public class StatCommand : Command
{ {
public StatCommand() : base("stats", "view your stats. syntax !stats", "xlrstats", Player.Permission.User, 0, false) { } public StatCommand() : base("stats", "view your stats. syntax !stats", "xlrstats", Player.Permission.User, 0, false) { }
@ -77,6 +19,27 @@ namespace SamplePlugin
} }
} }
public class topStats : Command
{
public topStats() : base("topstats", "view the top 5 players on this server. syntax !topstats", "!ts", Player.Permission.User, 0, false) { }
public override void Execute(Event E)
{
List<KeyValuePair<String, PlayerStats>> pStats = Stats.playerStats.topStats();
StringBuilder msgBlder = new StringBuilder();
E.Origin.Tell("^5--Top Players--");
foreach (KeyValuePair<String, PlayerStats> pStat in pStats)
{
Player P = E.Owner.clientDB.getPlayer(pStat.Key, -1);
if (P == null)
continue;
E.Origin.Tell(String.Format("^3{0}^7 - ^5{1} ^7KDR | ^5{2} ^7SKILL", P.Name, pStat.Value.KDR, pStat.Value.Skill));
}
}
}
public class Stats : Plugin public class Stats : Plugin
{ {
public static StatsDB playerStats { get; private set; } public static StatsDB playerStats { get; private set; }
@ -100,6 +63,10 @@ namespace SamplePlugin
{ {
foreach (Player P in E.Owner.getPlayers()) foreach (Player P in E.Owner.getPlayers())
{ {
if (P == null)
continue;
calculateAndSaveSkill(P); calculateAndSaveSkill(P);
resetCounters(P.clientID); resetCounters(P.clientID);
@ -116,6 +83,9 @@ namespace SamplePlugin
if (E.Type == Event.GType.Kill) if (E.Type == Event.GType.Kill)
{ {
if (E.Origin == E.Target)
return;
Player Killer = E.Origin; Player Killer = E.Origin;
PlayerStats killerStats = playerStats.getStats(Killer); PlayerStats killerStats = playerStats.getStats(Killer);
@ -127,20 +97,17 @@ namespace SamplePlugin
inactiveMinutes[E.Origin.clientID]++; inactiveMinutes[E.Origin.clientID]++;
} }
if (Killer != E.Target) killerStats.Kills++;
{
killerStats.Kills++;
if (killerStats.Deaths == 0) if (killerStats.Deaths == 0)
killerStats.KDR = killerStats.Kills; killerStats.KDR = killerStats.Kills;
else else
killerStats.KDR = (double)killerStats.Kills / (double)killerStats.Deaths; killerStats.KDR = killerStats.Kills / killerStats.Deaths;
playerStats.updateStats(Killer, killerStats); playerStats.updateStats(Killer, killerStats);
killStreaks[E.Origin.clientID]++; killStreaks[E.Origin.clientID]++;
deathStreaks[E.Origin.clientID] = 0; deathStreaks[E.Origin.clientID] = 0;
}
Killer.Tell(messageOnStreak(killStreaks[E.Origin.clientID], deathStreaks[E.Origin.clientID])); Killer.Tell(messageOnStreak(killStreaks[E.Origin.clientID], deathStreaks[E.Origin.clientID]));
} }
@ -151,7 +118,7 @@ namespace SamplePlugin
PlayerStats victimStats = playerStats.getStats(Victim); PlayerStats victimStats = playerStats.getStats(Victim);
victimStats.Deaths++; victimStats.Deaths++;
victimStats.KDR = (double)victimStats.Kills / (double)victimStats.Deaths; victimStats.KDR = victimStats.Kills / victimStats.Deaths;
playerStats.updateStats(Victim, victimStats); playerStats.updateStats(Victim, victimStats);
@ -164,6 +131,9 @@ namespace SamplePlugin
private void calculateAndSaveSkill(Player P) private void calculateAndSaveSkill(Player P)
{ {
if (P == null)
return;
PlayerStats disconnectStats = playerStats.getStats(P); PlayerStats disconnectStats = playerStats.getStats(P);
if (Kills[P.clientID] == 0) if (Kills[P.clientID] == 0)
return; return;
@ -172,8 +142,11 @@ namespace SamplePlugin
inactiveMinutes[P.clientID] += (int)(DateTime.Now - lastKill[P.clientID]).TotalMinutes; inactiveMinutes[P.clientID] += (int)(DateTime.Now - lastKill[P.clientID]).TotalMinutes;
int newPlayTime = (int)(DateTime.Now - connectionTime[P.clientID]).TotalMinutes - inactiveMinutes[P.clientID]; int newPlayTime = (int)(DateTime.Now - connectionTime[P.clientID]).TotalMinutes - inactiveMinutes[P.clientID];
double newSPM = Kills[P.clientID] * 50 / Math.Max(newPlayTime, 1);
if (newPlayTime < 2)
return;
double newSPM = Kills[P.clientID] * 50 / newPlayTime;
double kdrWeight = Math.Round(Math.Pow(disconnectStats.KDR, 2 / Math.E), 3); double kdrWeight = Math.Round(Math.Pow(disconnectStats.KDR, 2 / Math.E), 3);
double Multiplier; double Multiplier;
@ -282,7 +255,7 @@ namespace SamplePlugin
{ {
if (!File.Exists(FileName)) if (!File.Exists(FileName))
{ {
String Create = "CREATE TABLE [STATS] ( [npID] TEXT, [KILLS] INTEGER DEFAULT 0, [DEATHS] INTEGER DEFAULT 0, [KDR] TEXT DEFAULT 0, [SKILL] TEXT DEFAULT 0, [MEAN] REAL DEFAULT 0, [DEV] REAL DEFAULT 0, [SPM] TEXT DEFAULT 0, [PLAYTIME] INTEGER DEFAULT 0);"; String Create = "CREATE TABLE [STATS] ( [npID] TEXT, [KILLS] INTEGER DEFAULT 0, [DEATHS] INTEGER DEFAULT 0, [KDR] REAL DEFAULT 0, [SKILL] REAL DEFAULT 0, [MEAN] REAL DEFAULT 0, [DEV] REAL DEFAULT 0, [SPM] REAL DEFAULT 0, [PLAYTIME] INTEGER DEFAULT 0);";
ExecuteNonQuery(Create); ExecuteNonQuery(Create);
} }
} }
@ -340,6 +313,31 @@ namespace SamplePlugin
Update("STATS", updatedPlayer, String.Format("npID = '{0}'", P.npID)); Update("STATS", updatedPlayer, String.Format("npID = '{0}'", P.npID));
} }
public List<KeyValuePair<String, PlayerStats>> topStats()
{
String Query = String.Format("SELECT * FROM STATS WHERE KDR < '{0}' AND KILLS > '{1}' AND PLAYTIME > '{2}' ORDER BY SKILL DESC LIMIT '{3}'", 10, 150, 60, 5);
DataTable Result = GetDataTable(Query);
List<KeyValuePair<String, PlayerStats>> pStats = new List<KeyValuePair<String, PlayerStats>>();
if (Result != null && Result.Rows.Count > 0)
{
foreach (DataRow ResponseRow in Result.Rows)
{
pStats.Add( new KeyValuePair<String, PlayerStats>(ResponseRow["npID"].ToString(),
new PlayerStats(
Convert.ToInt32(ResponseRow["KILLS"]),
Convert.ToInt32(ResponseRow["DEATHS"]),
Convert.ToDouble(ResponseRow["KDR"]),
Convert.ToDouble(ResponseRow["SKILL"]),
Convert.ToDouble(ResponseRow["SPM"]),
Convert.ToInt32(ResponseRow["PLAYTIME"])
)
));
}
}
return pStats;
}
} }
public struct PlayerStats public struct PlayerStats

View File

@ -7,8 +7,8 @@
<ProjectGuid>{4785AB75-66F3-4391-985D-63A5A049A0FA}</ProjectGuid> <ProjectGuid>{4785AB75-66F3-4391-985D-63A5A049A0FA}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SamplePlugin</RootNamespace> <RootNamespace>StatsPlugin</RootNamespace>
<AssemblyName>SamplePlugin</AssemblyName> <AssemblyName>StatsPlugin</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
@ -30,8 +30,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="SharedLibary"> <Reference Include="SharedLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\SharedLibary\bin\Release\SharedLibary.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\Admin\lib\SharedLibrary.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

View File

@ -347,17 +347,17 @@ namespace Webfront_Plugin
npIDs.Add(B.npID); npIDs.Add(B.npID);
Player[] bannedPlayers = S.clientDB.getPlayers(npIDs).ToArray(); List<Player> bannedPlayers = S.clientDB.getPlayers(npIDs);
for (int i = 0; i < Bans.Count-1; i++) for (int i = 0; i < Bans.Count-1; i++)
{ {
if (Bans[i] == null) if (Bans[i] == null)
continue; continue;
Player P = bannedPlayers[i]; Player P = bannedPlayers.Where(x => x.npID == Bans[i].npID).First();
Player B; Player B;
if (P.npID == Bans[i].bannedByID) if (P.npID == Bans[i].bannedByID || Bans[i].bannedByID == "")
B = new Player("IW4MAdmin", "", 0, SharedLibrary.Player.Permission.Banned, 0, "", 0, ""); B = new Player("IW4MAdmin", "", 0, SharedLibrary.Player.Permission.Banned, 0, "", 0, "");
else else

View File

@ -33,8 +33,9 @@
<Reference Include="Kayak"> <Reference Include="Kayak">
<HintPath>..\Admin\bin\Release\lib\Kayak.dll</HintPath> <HintPath>..\Admin\bin\Release\lib\Kayak.dll</HintPath>
</Reference> </Reference>
<Reference Include="SharedLibary"> <Reference Include="SharedLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\SharedLibary\bin\Release\SharedLibary.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\Admin\lib\SharedLibrary.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />