From 1fb294b6178c3c02f19a6bf258361313b994b3f5 Mon Sep 17 00:00:00 2001 From: ASpoonPlaysGames <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:14:33 +0100 Subject: [PATCH 1/5] prevent crash when selecting first infected --- .../mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut index fef4c8b6c..945c32e08 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut @@ -44,8 +44,11 @@ void function SelectFirstInfectedDelayed() { wait 10.0 + RandomFloat( 5.0 ) - array players = GetPlayerArray() - entity infected = players[ RandomInt( players.len() ) ] + // wait until we have at least one player + while ( !GetPlayerArray().len() ) + wait 10.0 + + entity infected = GetPlayerArray().getrandom() InfectPlayer( infected ) RespawnInfected( infected ) From edde6d44c5ca3356d63d0677daf3c07aefe8970a Mon Sep 17 00:00:00 2001 From: ASpoonPlaysGames <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:17:36 +0100 Subject: [PATCH 2/5] end the round early instead --- .../scripts/vscripts/gamemodes/_gamemode_inf.gnut | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut index 945c32e08..baa662402 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut @@ -44,11 +44,16 @@ void function SelectFirstInfectedDelayed() { wait 10.0 + RandomFloat( 5.0 ) - // wait until we have at least one player - while ( !GetPlayerArray().len() ) - wait 10.0 + array players = GetPlayerArray() - entity infected = GetPlayerArray().getrandom() + if ( !players.len() ) + { + printt( "Couldn't select first infected: player array was empty" ) + SetWinner( INFECTION_TEAM_SURVIVOR ) + return + } + + entity infected = players.getrandom() InfectPlayer( infected ) RespawnInfected( infected ) From 53ba76a46ec00f0f866a84799063fa9d2765b814 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Thu, 4 Jan 2024 01:17:39 +0100 Subject: [PATCH 3/5] Add comment --- .../mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut | 1 + 1 file changed, 1 insertion(+) diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut index baa662402..81ee2e11c 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut @@ -46,6 +46,7 @@ void function SelectFirstInfectedDelayed() array players = GetPlayerArray() + // End game if server empty on infection select if ( !players.len() ) { printt( "Couldn't select first infected: player array was empty" ) From c80237c9ffe16479f5f26782359bb081945db00e Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Thu, 4 Jan 2024 01:18:23 +0100 Subject: [PATCH 4/5] Fix grammar in comment --- .../mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut index 81ee2e11c..02f0799a1 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut @@ -46,7 +46,7 @@ void function SelectFirstInfectedDelayed() array players = GetPlayerArray() - // End game if server empty on infection select + // End game if server empty on selecting infected if ( !players.len() ) { printt( "Couldn't select first infected: player array was empty" ) From 171209f7d04ed0b45a34c969ab78ffcf7ab9c36d Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Thu, 4 Jan 2024 01:21:58 +0100 Subject: [PATCH 5/5] Revert unrelated change --- .../mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut index 02f0799a1..c7175e749 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_inf.gnut @@ -54,7 +54,7 @@ void function SelectFirstInfectedDelayed() return } - entity infected = players.getrandom() + entity infected = players[ RandomInt( players.len() ) ] InfectPlayer( infected ) RespawnInfected( infected )