From 0aa2d0adb1812ed78a9dc3b4452f4ced01bed8f2 Mon Sep 17 00:00:00 2001 From: William Miller Date: Mon, 2 Sep 2024 20:23:10 -0300 Subject: Add `IsValidPlayer()` before flag return cleanup (#859) Add validity check to player validity as the thread of that function might end on via OnDestroy signal by disconnection, and by that point, the player is no longer valid. --- .../mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut index 90b20a8a..e52b0de5 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut @@ -453,9 +453,11 @@ void function TryReturnFlag( entity player, entity flag ) OnThreadEnd( function() : ( player ) { - // cleanup - Remote_CallFunction_NonReplay( player, "ServerCallback_CTF_StopReturnFlagProgressBar" ) - StopSoundOnEntity( player, "UI_CTF_1P_FlagReturnMeter" ) + if ( IsValidPlayer( player ) ) + { + Remote_CallFunction_NonReplay( player, "ServerCallback_CTF_StopReturnFlagProgressBar" ) + StopSoundOnEntity( player, "UI_CTF_1P_FlagReturnMeter" ) + } }) player.EndSignal( "FlagReturnEnded" ) -- cgit v1.2.3