small stat changes

This commit is contained in:
RaidMax 2019-08-24 20:15:50 -05:00
parent a820929582
commit 11d2df1fe8

View File

@ -430,21 +430,21 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
// get individual client's stats // get individual client's stats
var clientStats = playerStats[pl.ClientId]; var clientStats = playerStats[pl.ClientId];
// remove the client from the stats dictionary as they're leaving
playerStats.TryRemove(pl.ClientId, out _);
detectionStats.TryRemove(pl.ClientId, out _);
// sync their stats before they leave // sync their stats before they leave
clientStats = UpdateStats(clientStats); clientStats = UpdateStats(clientStats);
await SaveClientStats(clientStats); await SaveClientStats(clientStats);
// remove the client from the stats dictionary as they're leaving
playerStats.TryRemove(pl.ClientId, out _);
detectionStats.TryRemove(pl.ClientId, out _);
// increment the total play time // increment the total play time
serverStats.TotalPlayTime += pl.ConnectionLength; serverStats.TotalPlayTime += pl.ConnectionLength;
} }
private static async Task SaveClientStats(EFClientStatistics clientStats) private static async Task SaveClientStats(EFClientStatistics clientStats)
{ {
using (var ctx = new DatabaseContext(disableTracking: true)) using (var ctx = new DatabaseContext())
{ {
ctx.Update(clientStats); ctx.Update(clientStats);
await ctx.SaveChangesAsync(); await ctx.SaveChangesAsync();
@ -533,11 +533,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
await AddStandardKill(attacker, victim); await AddStandardKill(attacker, victim);
} }
if (hit.IsKillstreakKill)
{
return;
}
// incase the add player event get delayed // incase the add player event get delayed
if (!_servers[serverId].PlayerStats.ContainsKey(attacker.ClientId)) if (!_servers[serverId].PlayerStats.ContainsKey(attacker.ClientId))
{ {
@ -560,6 +555,11 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
await SaveClientStats(clientStats); await SaveClientStats(clientStats);
} }
if (hit.IsKillstreakKill)
{
return;
}
try try
{ {
if (Plugin.Config.Configuration().StoreClientKills) if (Plugin.Config.Configuration().StoreClientKills)