1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

Make stats update after 10 kills so we don't wait quite as long

Gracefully disconnect clients on shutting down again
This commit is contained in:
RaidMax
2019-08-24 10:02:53 -05:00
parent 981d698f70
commit 5873121780
4 changed files with 55 additions and 15 deletions

View File

@ -436,15 +436,19 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
// sync their stats before they leave
clientStats = UpdateStats(clientStats);
await SaveClientStats(clientStats);
// increment the total play time
serverStats.TotalPlayTime += pl.ConnectionLength;
}
private static async Task SaveClientStats(EFClientStatistics clientStats)
{
using (var ctx = new DatabaseContext(disableTracking: true))
{
ctx.Update(clientStats);
await ctx.SaveChangesAsync();
}
// increment the total play time
serverStats.TotalPlayTime += pl.ConnectionLength;
}
public void AddDamageEvent(string eventLine, int attackerClientId, int victimClientId, long serverId)
@ -551,6 +555,11 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
clientStats.HitLocations.Single(hl => hl.Location == hit.HitLoc).HitCount += 1;
}
if (clientStats.SessionKills % Detection.MAX_TRACKED_HIT_COUNT == 0)
{
await SaveClientStats(clientStats);
}
try
{
if (Plugin.Config.Configuration().StoreClientKills)