From c5370fb4fd7e5ee7379fdea00c6256203c4c79d9 Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 1 Nov 2024 15:43:14 -0700 Subject: [PATCH] Do valid check before equality --- mod/Jailbreak.Warden/Global/WardenBehavior.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mod/Jailbreak.Warden/Global/WardenBehavior.cs b/mod/Jailbreak.Warden/Global/WardenBehavior.cs index 7bf099b..d681f8a 100644 --- a/mod/Jailbreak.Warden/Global/WardenBehavior.cs +++ b/mod/Jailbreak.Warden/Global/WardenBehavior.cs @@ -249,7 +249,7 @@ public bool TryRemoveWarden(bool isPass = false) { var stats = API.Gangs?.Services.GetService(); if (stats != null) { var wrapper = new PlayerWrapper(Warden); - // Task.Run(async () => await updateWardenDeathStats(wrapper)); + Task.Run(async () => await updateWardenDeathStats(wrapper)); } } } @@ -300,7 +300,7 @@ public HookResult OnDeath(EventPlayerDeath ev, GameEventInfo info) { if (player == null || !player.IsValid) return HookResult.Continue; var isWarden = ((IWardenService)this).IsWarden(ev.Userid); if (API.Gangs != null) { - if (ev.Attacker != null && ev.Attacker != player && ev.Attacker.IsValid + if (ev.Attacker != null && ev.Attacker.IsValid && ev.Attacker != player && isWarden) { var wrapper = new PlayerWrapper(ev.Attacker); Task.Run(async () => await incrementWardenKills(wrapper)); @@ -311,8 +311,7 @@ public HookResult OnDeath(EventPlayerDeath ev, GameEventInfo info) { // If the guard is the warden, update all guards' stats // If the guard is not the warden, only update the warden's stats if (guard.SteamID == player.SteamID != isWarden) continue; - Task.Run( - async () => { await updateGuardDeathStats(wrapper, isWarden); }); + Task.Run(async () => await updateGuardDeathStats(wrapper, isWarden)); } } @@ -356,6 +355,8 @@ private async Task // The guard let the warden die stat.WardenDeathsAsGuard++; } + + await stats.SetForPlayer(player, WardenStat.STAT_ID, stat); } [GameEventHandler]