aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/state_client.nut
diff options
context:
space:
mode:
authorEmma Miler <27428383+emma-miler@users.noreply.github.com>2022-03-27 00:45:23 +0100
committerGitHub <noreply@github.com>2022-03-27 00:45:23 +0100
commit3e7186801d70e50a9135b897ef572076fe442cf4 (patch)
tree80e535d881b8e90a5c4e3b2c2b8ac733ba163c84 /Northstar.Client/mod/scripts/vscripts/state_client.nut
parentbd102d798a0b9db2dcbd6bd4045fb84c53fc031a (diff)
downloadNorthstarMods-3e7186801d70e50a9135b897ef572076fe442cf4.tar.gz
NorthstarMods-3e7186801d70e50a9135b897ef572076fe442cf4.zip
Add mod code for updating state for discord RPC (#274)v1.6.0-rc3
Diffstat (limited to 'Northstar.Client/mod/scripts/vscripts/state_client.nut')
-rw-r--r--Northstar.Client/mod/scripts/vscripts/state_client.nut48
1 files changed, 48 insertions, 0 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/state_client.nut b/Northstar.Client/mod/scripts/vscripts/state_client.nut
new file mode 100644
index 00000000..9ebcf006
--- /dev/null
+++ b/Northstar.Client/mod/scripts/vscripts/state_client.nut
@@ -0,0 +1,48 @@
+untyped
+
+int highestScore = 0
+int secondHighestScore = 0
+int ourScore = 0
+
+globalize_all_functions
+
+void function OnPrematchStart()
+{
+ if (GetServerVar( "roundBased" ))
+ NSUpdateTimeInfo( level.nv.roundEndTime - Time() )
+ else
+ NSUpdateTimeInfo( level.nv.gameEndTime - Time() )
+}
+
+void function NSUpdateGameStateClientStart()
+{
+ AddCallback_GameStateEnter( eGameState.Prematch, OnPrematchStart )
+ thread NSUpdateGameStateLoopClient()
+ OnPrematchStart()
+}
+
+void function NSUpdateGameStateLoopClient()
+{
+ while ( true )
+ {
+ foreach ( player in GetPlayerArray() )
+ {
+ if ( GameRules_GetTeamScore( player.GetTeam() ) >= highestScore )
+ {
+ highestScore = GameRules_GetTeamScore( player.GetTeam() )
+ }
+ else if ( GameRules_GetTeamScore( player.GetTeam() ) > secondHighestScore )
+ {
+ secondHighestScore = GameRules_GetTeamScore( player.GetTeam() )
+ }
+ }
+ if ( GetLocalClientPlayer() != null )
+ {
+ ourScore = GameRules_GetTeamScore( GetLocalClientPlayer().GetTeam() )
+ }
+ int limit = GetServerVar( "roundBased" ) ? GetCurrentPlaylistVarInt( "roundscorelimit", 0 ) : GetCurrentPlaylistVarInt( "scorelimit", 0 )
+ NSUpdateGameStateClient( GetPlayerArray().len(), ourScore, secondHighestScore, highestScore, GetServerVar( "roundBased" ), limit )
+ OnPrematchStart()
+ wait 1.0
+ }
+} \ No newline at end of file