From 520468f0558e072005047577350a8347fbb11aa0 Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sat, 7 Sep 2024 20:11:49 -0300 Subject: [PATCH 01/12] Changeteam feature --- .../mod/scripts/vscripts/ui/menu_ingame.nut | 12 ++++++++---- Northstar.CustomServers/mod.json | 4 ++++ .../scripts/vscripts/mp/_base_gametype_mp.gnut | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut index 35c9e9bae..7cea329ad 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut @@ -85,10 +85,8 @@ void function InitInGameMPMenu() var gameHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_GAME" ) var leaveButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#LEAVE_MATCH" ) Hud_AddEventHandler( leaveButton, UIE_CLICK, OnLeaveButton_Activate ) - #if DEV - var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "Dev" ) - Hud_AddEventHandler( devButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "DevMenu" ) ) ) - #endif + var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" ) + Hud_AddEventHandler( devButton, UIE_CLICK, OnRequestTeamSwitch ) headerIndex++ buttonIndex = 0 @@ -700,3 +698,9 @@ void function SetTitanSelectButtonVisibleState( bool state ) Hud_Hide( file.titanSelectButton ) } } + +void function OnRequestTeamSwitch( var button ) +{ + ClientCommand( "changeteam" ) + CloseAllMenus() +} diff --git a/Northstar.CustomServers/mod.json b/Northstar.CustomServers/mod.json index fa51f4d41..ef42e647c 100644 --- a/Northstar.CustomServers/mod.json +++ b/Northstar.CustomServers/mod.json @@ -49,6 +49,10 @@ "Name": "ns_progression_enabled", "DefaultValue": "0", "Flags": "ARCHIVE_PLAYERPROFILE" + }, + { + "Name": "ns_allow_team_change", + "DefaultValue": "1" } ], "Scripts": [ diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index b77a37b2a..c86d022e1 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -34,6 +34,7 @@ struct { void function BaseGametype_Init_MPSP() { + AddClientCommandCallback( "changeteam", ClientCommandCallbackChangeTeam ) AddSpawnCallback( "info_intermission", SetIntermissionCamera ) AddPostDamageCallback( "player", AddToTitanDamageStat ) @@ -630,6 +631,22 @@ void function SetRecalculateRespawnAsTitanStartPointCallback( entity functionref file.recalculateRespawnAsTitanStartPointCallback = callbackFunc } +bool function ClientCommandCallbackChangeTeam( entity player, array args ) +{ + if ( !GetConVarBool( "ns_allow_team_change" ) ) + { + SendHudMessage( player, "Server does not allow team change", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + return true + } + + if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() && GamePlaying() ) + SetTeam( player, GetOtherTeam( player.GetTeam() ) ) + else + SendHudMessage( player, "Current gamemode doesn't support team change", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + + return true +} + // stuff to change later bool function ShouldEntTakeDamage_SPMP( entity ent, var damageInfo ) From 4cddc1a302e4166fd226a1a2a817f988bd6c2ffd Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sat, 7 Sep 2024 20:22:27 -0300 Subject: [PATCH 02/12] Buffer by time the ability to change teams --- .../mod/scripts/vscripts/mp/_base_gametype_mp.gnut | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index c86d022e1..62f3fe53b 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -30,6 +30,7 @@ struct { array specCams entity functionref( entity player, entity basePoint ) recalculateRespawnAsTitanStartPointCallback + table playerChangeTeamTimeBuffer } file void function BaseGametype_Init_MPSP() @@ -638,6 +639,17 @@ bool function ClientCommandCallbackChangeTeam( entity player, array args SendHudMessage( player, "Server does not allow team change", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) return true } + + if ( !( player in file.playerChangeTeamTimeBuffer ) ) + file.playerChangeTeamTimeBuffer[ player ] <- Time() + 5 + else + { + if ( file.playerChangeTeamTimeBuffer[ player ] > Time() ) + { + SendHudMessage( player, "Team Switching is on Cooldown", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + return true + } + } if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() && GamePlaying() ) SetTeam( player, GetOtherTeam( player.GetTeam() ) ) From d7b0678eb278b6747647c12c8e048225a15e801b Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sat, 7 Sep 2024 20:38:28 -0300 Subject: [PATCH 03/12] Replicate convar, hide button on disable --- Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut | 8 ++++++-- Northstar.CustomServers/mod.json | 3 ++- .../mod/scripts/vscripts/mp/_base_gametype_mp.gnut | 6 ------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut index 7cea329ad..86fc08a27 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut @@ -85,8 +85,12 @@ void function InitInGameMPMenu() var gameHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_GAME" ) var leaveButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#LEAVE_MATCH" ) Hud_AddEventHandler( leaveButton, UIE_CLICK, OnLeaveButton_Activate ) - var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" ) - Hud_AddEventHandler( devButton, UIE_CLICK, OnRequestTeamSwitch ) + + if ( GetConVarBool( "ns_allow_team_change" ) ) + { + var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" ) + Hud_AddEventHandler( devButton, UIE_CLICK, OnRequestTeamSwitch ) + } headerIndex++ buttonIndex = 0 diff --git a/Northstar.CustomServers/mod.json b/Northstar.CustomServers/mod.json index ef42e647c..6735306e6 100644 --- a/Northstar.CustomServers/mod.json +++ b/Northstar.CustomServers/mod.json @@ -52,7 +52,8 @@ }, { "Name": "ns_allow_team_change", - "DefaultValue": "1" + "DefaultValue": "1", + "Flags": "REPLICATED" } ], "Scripts": [ diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index 62f3fe53b..90278c6d9 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -634,12 +634,6 @@ void function SetRecalculateRespawnAsTitanStartPointCallback( entity functionref bool function ClientCommandCallbackChangeTeam( entity player, array args ) { - if ( !GetConVarBool( "ns_allow_team_change" ) ) - { - SendHudMessage( player, "Server does not allow team change", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) - return true - } - if ( !( player in file.playerChangeTeamTimeBuffer ) ) file.playerChangeTeamTimeBuffer[ player ] <- Time() + 5 else From c4c3a780fdbdf5f02d0f1d3fae28fa9bdbea7663 Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sun, 8 Sep 2024 17:56:43 -0300 Subject: [PATCH 04/12] Changes requested --- .../mod/scripts/vscripts/ui/menu_ingame.nut | 30 ++++++++++++++----- .../vscripts/mp/_base_gametype_mp.gnut | 12 +++++++- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut index 86fc08a27..d38956c93 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut @@ -85,12 +85,14 @@ void function InitInGameMPMenu() var gameHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_GAME" ) var leaveButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#LEAVE_MATCH" ) Hud_AddEventHandler( leaveButton, UIE_CLICK, OnLeaveButton_Activate ) - - if ( GetConVarBool( "ns_allow_team_change" ) ) - { - var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" ) - Hud_AddEventHandler( devButton, UIE_CLICK, OnRequestTeamSwitch ) - } + #if DEV + var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "Dev" ) + Hud_AddEventHandler( devButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "DevMenu" ) ) ) + #else + var teamChangeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" ) + Hud_AddEventHandler( teamChangeButton, UIE_CLICK, OnRequestTeamSwitch ) + thread UpdateTeamSwitchButton( teamChangeButton ) + #endif headerIndex++ buttonIndex = 0 @@ -703,8 +705,20 @@ void function SetTitanSelectButtonVisibleState( bool state ) } } +void function UpdateTeamSwitchButton( var button ) +{ + while( true ) + { + Hud_SetLocked( button, !GetConVarBool( "ns_allow_team_change" ) ) + wait 0.5 + } +} + void function OnRequestTeamSwitch( var button ) { - ClientCommand( "changeteam" ) - CloseAllMenus() + if( !Hud_IsLocked( button ) ) + { + ClientCommand( "changeteam" ) + CloseAllMenus() + } } diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index 90278c6d9..e44e7689f 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -634,8 +634,13 @@ void function SetRecalculateRespawnAsTitanStartPointCallback( entity functionref bool function ClientCommandCallbackChangeTeam( entity player, array args ) { + if ( !GetConVarBool( "ns_allow_team_change" ) ) + return true + if ( !( player in file.playerChangeTeamTimeBuffer ) ) + { file.playerChangeTeamTimeBuffer[ player ] <- Time() + 5 + } else { if ( file.playerChangeTeamTimeBuffer[ player ] > Time() ) @@ -645,7 +650,12 @@ bool function ClientCommandCallbackChangeTeam( entity player, array args } } - if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() && GamePlaying() ) + if( !GamePlaying() ) + { + SendHudMessage( player, "Team change not allowed outside playing phase", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + return true + } + if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() ) SetTeam( player, GetOtherTeam( player.GetTeam() ) ) else SendHudMessage( player, "Current gamemode doesn't support team change", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) From 2fe08c91f8d8be6511d4a1d6f95af095310ca21a Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sun, 8 Sep 2024 18:00:24 -0300 Subject: [PATCH 05/12] Remove from else block --- Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut index d38956c93..efb3a93d5 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut @@ -85,13 +85,12 @@ void function InitInGameMPMenu() var gameHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_GAME" ) var leaveButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#LEAVE_MATCH" ) Hud_AddEventHandler( leaveButton, UIE_CLICK, OnLeaveButton_Activate ) + var teamChangeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" ) + Hud_AddEventHandler( teamChangeButton, UIE_CLICK, OnRequestTeamSwitch ) + thread UpdateTeamSwitchButton( teamChangeButton ) #if DEV var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "Dev" ) Hud_AddEventHandler( devButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "DevMenu" ) ) ) - #else - var teamChangeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" ) - Hud_AddEventHandler( teamChangeButton, UIE_CLICK, OnRequestTeamSwitch ) - thread UpdateTeamSwitchButton( teamChangeButton ) #endif headerIndex++ From 4c5bf08fcd8e1cc84e1005507de7bd521bd7a127 Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sun, 8 Sep 2024 18:01:14 -0300 Subject: [PATCH 06/12] Update menu_ingame.nut --- Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut index efb3a93d5..ab24f5afa 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut @@ -706,7 +706,7 @@ void function SetTitanSelectButtonVisibleState( bool state ) void function UpdateTeamSwitchButton( var button ) { - while( true ) + while ( true ) { Hud_SetLocked( button, !GetConVarBool( "ns_allow_team_change" ) ) wait 0.5 @@ -715,7 +715,7 @@ void function UpdateTeamSwitchButton( var button ) void function OnRequestTeamSwitch( var button ) { - if( !Hud_IsLocked( button ) ) + if ( !Hud_IsLocked( button ) ) { ClientCommand( "changeteam" ) CloseAllMenus() From 5e932891c99358469661c2538ca1f5f0932b5697 Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sun, 8 Sep 2024 18:02:09 -0300 Subject: [PATCH 07/12] Formatting --- .../mod/scripts/vscripts/mp/_base_gametype_mp.gnut | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index e44e7689f..2686773b5 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -650,7 +650,7 @@ bool function ClientCommandCallbackChangeTeam( entity player, array args } } - if( !GamePlaying() ) + if ( !GamePlaying() ) { SendHudMessage( player, "Team change not allowed outside playing phase", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) return true From 30e064cdea9221019150bc87c2bbe24d6a81d080 Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sun, 8 Sep 2024 18:03:10 -0300 Subject: [PATCH 08/12] Update buffer timer on click --- .../mod/scripts/vscripts/mp/_base_gametype_mp.gnut | 1 + 1 file changed, 1 insertion(+) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index 2686773b5..8c419e0e0 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -646,6 +646,7 @@ bool function ClientCommandCallbackChangeTeam( entity player, array args if ( file.playerChangeTeamTimeBuffer[ player ] > Time() ) { SendHudMessage( player, "Team Switching is on Cooldown", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + file.playerChangeTeamTimeBuffer[ player ] = Time() + 5 return true } } From a96a9ec63c42a5a7004ff06e5e36b7c0d9187e4a Mon Sep 17 00:00:00 2001 From: Zanieon Date: Sun, 8 Sep 2024 18:37:41 -0300 Subject: [PATCH 09/12] Localization --- .../mod/resource/northstar_client_localisation_english.txt | 5 +++++ .../mod/scripts/vscripts/mp/_base_gametype_mp.gnut | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt index 29d7cddf8..4212ca085 100644 --- a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt +++ b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt @@ -312,6 +312,11 @@ Press Yes if you agree to this. This choice can be changed in the mods menu at a // In-game chat "HUD_CHAT_WHISPER_PREFIX" "[WHISPER]" "HUD_CHAT_SERVER_PREFIX" "[SERVER]" + + // Team Switching + "TEAMSWITCH_BUFFER" "Team Switching is on Cooldown" + "TEAMSWITCH_GAMEPLAY" "Team change not allowed outside playing phase" + "TEAMSWITCH_DISABLED" "Current gamemode doesn't support team change" "NO_GAMESERVER_RESPONSE" "Couldn't reach game server" "BAD_GAMESERVER_RESPONSE" "Game server gave an invalid response" diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index 8c419e0e0..0d6b3154c 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -645,7 +645,7 @@ bool function ClientCommandCallbackChangeTeam( entity player, array args { if ( file.playerChangeTeamTimeBuffer[ player ] > Time() ) { - SendHudMessage( player, "Team Switching is on Cooldown", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + SendHudMessage( player, "#TEAMSWITCH_BUFFER", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) file.playerChangeTeamTimeBuffer[ player ] = Time() + 5 return true } @@ -653,13 +653,13 @@ bool function ClientCommandCallbackChangeTeam( entity player, array args if ( !GamePlaying() ) { - SendHudMessage( player, "Team change not allowed outside playing phase", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + SendHudMessage( player, "#TEAMSWITCH_GAMEPLAY", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) return true } if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() ) SetTeam( player, GetOtherTeam( player.GetTeam() ) ) else - SendHudMessage( player, "Current gamemode doesn't support team change", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) + SendHudMessage( player, "#TEAMSWITCH_DISABLED", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) return true } From b0f52ab31b609e2f0379f4a3088f007348b74330 Mon Sep 17 00:00:00 2001 From: Zanieon Date: Wed, 11 Sep 2024 20:28:03 -0300 Subject: [PATCH 10/12] Update _base_gametype_mp.gnut --- .../mod/scripts/vscripts/mp/_base_gametype_mp.gnut | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index 0d6b3154c..406b8d68d 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -639,18 +639,20 @@ bool function ClientCommandCallbackChangeTeam( entity player, array args if ( !( player in file.playerChangeTeamTimeBuffer ) ) { - file.playerChangeTeamTimeBuffer[ player ] <- Time() + 5 + file.playerChangeTeamTimeBuffer[ player ] <- Time() + 5.0 } else { if ( file.playerChangeTeamTimeBuffer[ player ] > Time() ) { SendHudMessage( player, "#TEAMSWITCH_BUFFER", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) - file.playerChangeTeamTimeBuffer[ player ] = Time() + 5 return true } } + if ( player in file.playerChangeTeamTimeBuffer && file.playerChangeTeamTimeBuffer[ player ] < Time() ) + file.playerChangeTeamTimeBuffer[ player ] = Time() + 5.0 + if ( !GamePlaying() ) { SendHudMessage( player, "#TEAMSWITCH_GAMEPLAY", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) From b52bca88f9ccd83d510a7685d482b2355d21f6b4 Mon Sep 17 00:00:00 2001 From: Zanieon Date: Fri, 13 Sep 2024 13:18:10 -0300 Subject: [PATCH 11/12] Update menu_ingame.nut --- Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut index ab24f5afa..ac617a9c7 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut @@ -87,7 +87,7 @@ void function InitInGameMPMenu() Hud_AddEventHandler( leaveButton, UIE_CLICK, OnLeaveButton_Activate ) var teamChangeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" ) Hud_AddEventHandler( teamChangeButton, UIE_CLICK, OnRequestTeamSwitch ) - thread UpdateTeamSwitchButton( teamChangeButton ) + thread UpdateTeamSwitchButton_Threaded( teamChangeButton ) #if DEV var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "Dev" ) Hud_AddEventHandler( devButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "DevMenu" ) ) ) @@ -704,7 +704,7 @@ void function SetTitanSelectButtonVisibleState( bool state ) } } -void function UpdateTeamSwitchButton( var button ) +void function UpdateTeamSwitchButton_Threaded( var button ) { while ( true ) { From 0873e03bbc8ec347fb8001ff5871142f1fc29065 Mon Sep 17 00:00:00 2001 From: Zanieon Date: Wed, 30 Oct 2024 18:43:44 -0300 Subject: [PATCH 12/12] Include Spectators to not be allowed to switch --- .../mod/scripts/vscripts/mp/_base_gametype_mp.gnut | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index 406b8d68d..eb8a4c0ec 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -634,7 +634,7 @@ void function SetRecalculateRespawnAsTitanStartPointCallback( entity functionref bool function ClientCommandCallbackChangeTeam( entity player, array args ) { - if ( !GetConVarBool( "ns_allow_team_change" ) ) + if ( !GetConVarBool( "ns_allow_team_change" ) || IsPrivateMatchSpectator( player ) ) return true if ( !( player in file.playerChangeTeamTimeBuffer ) )