aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut
blob: 755396e3032391023cfb63c71eedef838c30caf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
untyped
globalize_all_functions

struct {
	int highestScore = 0
	int secondHighestScore = 0
} file

void function OnPrematchStart()
{
    if ( GetServerVar( "roundBased" ) )
        NSUpdateTimeInfo( level.nv.roundEndTime - Time() )
    else
        NSUpdateTimeInfo( level.nv.gameEndTime - Time() )
}

void function NSUpdateGameStateClientStart()
{
    #if MP
		AddCallback_GameStateEnter( eGameState.Prematch, OnPrematchStart )
    #endif
	
    thread NSUpdateGameStateLoopClient()
    OnPrematchStart()
}

void function NSUpdateGameStateLoopClient()
{
    while ( true )
    {
		if ( IsSingleplayer() )
		{
			NSUpdateGameStateClient( GetPlayerArray().len(), GetCurrentPlaylistVarInt( "max_players", 65535 ), 1, 1, 1, GetServerVar( "roundBased" ), 1 )
			wait 1.0
		}
		else
		{
			foreach ( player in GetPlayerArray() )
			{
				if ( GameRules_GetTeamScore( player.GetTeam() ) >= file.highestScore )
				{
					file.highestScore = GameRules_GetTeamScore( player.GetTeam() )
				}
				else if ( GameRules_GetTeamScore( player.GetTeam() ) > file.secondHighestScore )
				{
					file.secondHighestScore = GameRules_GetTeamScore( player.GetTeam() )
				}
			}
			
			int ourScore = 0
			if ( IsValid( GetLocalClientPlayer() ) )
				ourScore = GameRules_GetTeamScore( GetLocalClientPlayer().GetTeam() )
			
			int limit = IsRoundBased() ? GetCurrentPlaylistVarInt( "roundscorelimit", 0 ) : GetCurrentPlaylistVarInt( "scorelimit", 0 )
			NSUpdateGameStateClient( GetPlayerArray().len(), GetCurrentPlaylistVarInt( "max_players", 65535 ), ourScore, file.secondHighestScore, file.highestScore, GetServerVar( "roundBased" ), limit )
			OnPrematchStart()
			wait 1.0
		}
    }
}