aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/state_client.nut
blob: 9ebcf00694e57762a30cbdb47a972f56db9480f6 (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
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
    }
}