From 44505833b1fb686c614e75d8269f23f0bc3173c4 Mon Sep 17 00:00:00 2001 From: Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Thu, 4 Jan 2024 00:26:31 +0000 Subject: Prevent crash when selecting first infected (#731) End match early if there are no players when trying to select infected --- .../mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Northstar.Custom/mod') diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut index fef4c8b6c..c7175e749 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut @@ -45,6 +45,15 @@ void function SelectFirstInfectedDelayed() wait 10.0 + RandomFloat( 5.0 ) array players = GetPlayerArray() + + // End game if server empty on selecting infected + if ( !players.len() ) + { + printt( "Couldn't select first infected: player array was empty" ) + SetWinner( INFECTION_TEAM_SURVIVOR ) + return + } + entity infected = players[ RandomInt( players.len() ) ] InfectPlayer( infected ) -- cgit v1.2.3