diff --git a/Plugins/SimpleStats/Cheat/Detection.cs b/Plugins/SimpleStats/Cheat/Detection.cs index e036a2f81..5958708f9 100644 --- a/Plugins/SimpleStats/Cheat/Detection.cs +++ b/Plugins/SimpleStats/Cheat/Detection.cs @@ -271,7 +271,8 @@ if (totalChestKills >= 250) double chestAbdomenRatioLerpValueForFlag = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdLowSample(2.25), Thresholds.ChestAbdomenRatioThresholdHighSample(2.25), lerpAmount) + marginOfError; double chestAbdomenLerpValueForBan = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdLowSample(3.0), Thresholds.ChestAbdomenRatioThresholdHighSample(3.0), lerpAmount) + marginOfError; - double currentChestAbdomenRatio = HitLocationCount[IW4Info.HitLocation.torso_upper] / (double)HitLocationCount[IW4Info.HitLocation.torso_lower]; + double currentChestAbdomenRatio = stats.HitLocations.Single(hl => hl.Location == IW4Info.HitLocation.torso_upper).HitCount / + stats.HitLocations.Single(hl => hl.Location == IW4Info.HitLocation.torso_lower).HitCount; if (currentChestAbdomenRatio > chestAbdomenRatioLerpValueForFlag) { @@ -284,8 +285,8 @@ if (totalChestKills >= 250) Log.WriteDebug($"**Ratio {currentChestAbdomenRatio}"); Log.WriteDebug($"**MaxRatio {chestAbdomenLerpValueForBan}"); var sb = new StringBuilder(); - foreach (var kvp in HitLocationCount) - sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n"); + foreach (var location in stats.HitLocations) + sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n"); Log.WriteDebug(sb.ToString()); // Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}"); @@ -305,8 +306,8 @@ if (totalChestKills >= 250) Log.WriteDebug($"**Ratio {currentChestAbdomenRatio}"); Log.WriteDebug($"**MaxRatio {chestAbdomenRatioLerpValueForFlag}"); var sb = new StringBuilder(); - foreach (var kvp in HitLocationCount) - sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n"); + foreach (var location in stats.HitLocations) + sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n"); Log.WriteDebug(sb.ToString()); // Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}"); diff --git a/Plugins/SimpleStats/Models/EFClientStatistics.cs b/Plugins/SimpleStats/Models/EFClientStatistics.cs index f929ba4c8..ecd15eb65 100644 --- a/Plugins/SimpleStats/Models/EFClientStatistics.cs +++ b/Plugins/SimpleStats/Models/EFClientStatistics.cs @@ -42,7 +42,7 @@ namespace StatsPlugin.Models [NotMapped] public float AverageHitOffset { - get => (float)Math.Round(HitLocations.Sum(c => c.HitOffsetAverage) / HitLocations.Where(c => c.HitOffsetAverage > 0).Count(), 4); + get => (float)Math.Round(HitLocations.Sum(c => c.HitOffsetAverage) / Math.Max(1, HitLocations.Where(c => c.HitOffsetAverage > 0).Count()), 4); } [NotMapped] public int SessionKills { get; set; } diff --git a/Plugins/SimpleStats/Plugin.cs b/Plugins/SimpleStats/Plugin.cs index 0da3d0f70..05d6b2f8d 100644 --- a/Plugins/SimpleStats/Plugin.cs +++ b/Plugins/SimpleStats/Plugin.cs @@ -129,7 +129,7 @@ namespace StatsPlugin (double)clientStats.Where(c => c.HitLocations.Count > 0) .Sum(c => c.HitLocations.Where(hl => hl.Location != IW4Info.HitLocation.none).Sum(f => f.HitCount)), 2); - hitOffsetAverage = clientStats.Sum(c => c.AverageHitOffset) / clientStats.Where(c => c.AverageHitOffset > 0).Count(); + hitOffsetAverage = clientStats.Sum(c => c.AverageHitOffset) / Math.Max(1, clientStats.Where(c => c.AverageHitOffset > 0).Count()); } return new List() diff --git a/WebfrontCore/Controllers/ClientController.cs b/WebfrontCore/Controllers/ClientController.cs index 237d54c9a..7020b6f0e 100644 --- a/WebfrontCore/Controllers/ClientController.cs +++ b/WebfrontCore/Controllers/ClientController.cs @@ -45,7 +45,7 @@ namespace WebfrontCore.Controllers var administeredPenaltiesMeta = await Manager.GetPenaltyService() .ReadGetClientPenaltiesAsync(client.ClientId, false); - if (client.Level > SharedLibrary.Objects.Player.Permission.Trusted) + if (Authorized && client.Level > SharedLibrary.Objects.Player.Permission.Trusted) clientDto.Meta.Add(new ProfileMeta() { Key = "Masked", diff --git a/WebfrontCore/Controllers/ServerController.cs b/WebfrontCore/Controllers/ServerController.cs index 645453402..fadf0a61d 100644 --- a/WebfrontCore/Controllers/ServerController.cs +++ b/WebfrontCore/Controllers/ServerController.cs @@ -30,7 +30,8 @@ namespace WebfrontCore.Controllers Players = s.Players.Where(p => p != null).Select(p => new PlayerInfo { Name = p.Name, - ClientId = p.ClientId + ClientId = p.ClientId, + Level = p.Level.ToString() }).ToList(), ChatHistory = s.ChatHistory.OrderBy(c => c.Time).Take((int)Math.Ceiling(s.ClientNum / 2.0)).ToArray(), PlayerHistory = s.PlayerHistory.ToArray() diff --git a/WebfrontCore/Views/Server/_ClientActivity.cshtml b/WebfrontCore/Views/Server/_ClientActivity.cshtml index b7f4f2b42..a2843b4ce 100644 --- a/WebfrontCore/Views/Server/_ClientActivity.cshtml +++ b/WebfrontCore/Views/Server/_ClientActivity.cshtml @@ -8,7 +8,7 @@ @{ for (int i = 0; i < Model.ChatHistory.Length; i++) { - string message = "– " + @Model.ChatHistory[i].Message; + string message = @Model.ChatHistory[i].Message; if (Model.ChatHistory[i].Message == "CONNECTED") { @Model.ChatHistory[i].Name
@@ -20,7 +20,7 @@ } if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED") { - @Model.ChatHistory[i].Name @Html.Raw(@message)
+ @Model.ChatHistory[i].Name — @message.Substring(0, Math.Min(50, message.Length - 1))
} } } @@ -31,7 +31,8 @@ @{ for (int i = 0; i < half; i++) { - @Html.ActionLink(Model.Players[i].Name, "ProfileAsync", "Client", new { id = Model.Players[i].ClientId })
+ string levelColorClass = !ViewBag.Authorized ? "" : $"level-color-{Model.Players[i].Level.ToLower()}"; + @Html.ActionLink(Model.Players[i].Name, "ProfileAsync", "Client", new { id = Model.Players[i].ClientId }, new { @class=levelColorClass })
} } @@ -39,7 +40,8 @@ @{ for (int i = half; i < Model.ClientCount; i++) { - @Html.ActionLink(Model.Players[i].Name, "ProfileAsync", "Client", new { id = Model.Players[i].ClientId })
+ string levelColorClass = !ViewBag.Authorized ? "" : $"level-color-{Model.Players[i].Level.ToLower()}"; + @Html.ActionLink(Model.Players[i].Name, "ProfileAsync", "Client", new { id = Model.Players[i].ClientId }, new { @class = levelColorClass })
} } diff --git a/WebfrontCore/Views/Shared/_Layout.cshtml b/WebfrontCore/Views/Shared/_Layout.cshtml index fbad5595e..a28d73a56 100644 --- a/WebfrontCore/Views/Shared/_Layout.cshtml +++ b/WebfrontCore/Views/Shared/_Layout.cshtml @@ -46,6 +46,7 @@ + +