aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut
blob: f17216fbc17c1ac8df050ef40c1224dff357df39 (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
untyped
globalize_all_functions

GameStateStruct function DiscordRPC_GenerateGameState( GameStateStruct gs )
{
    int highestScore = 0
    int secondHighest = 0

    foreach ( player in GetPlayerArray() )
    {
        if ( GameRules_GetTeamScore( player.GetTeam() ) >= highestScore )
        {
            highestScore = GameRules_GetTeamScore( player.GetTeam() )
        }
        else if ( GameRules_GetTeamScore( player.GetTeam() ) > secondHighest )
        {
            secondHighest = GameRules_GetTeamScore( player.GetTeam() )
        }
    }

    gs.map = GetMapName()
    gs.mapDisplayname = Localize(GetMapDisplayName(GetMapName()))

    gs.playlist = GetCurrentPlaylistName()
    gs.playlistDisplayname = Localize(GetCurrentPlaylistVarString("name", GetCurrentPlaylistName()))

    gs.currentPlayers = GetPlayerArray().len()
    gs.maxPlayers = GetCurrentPlaylistVarInt( "maxPlayers", -1 )

    if ( IsValid( GetLocalClientPlayer() ) )
		gs.ownScore = GameRules_GetTeamScore( GetLocalClientPlayer().GetTeam() )

    gs.otherHighestScore = gs.ownScore == highestScore ? secondHighest : highestScore

    gs.maxScore = IsRoundBased() ? GetCurrentPlaylistVarInt( "roundscorelimit", 0 ) : GetCurrentPlaylistVarInt( "scorelimit", 0 )

	if ( GetServerVar( "roundBased" ) )
		gs.timeEnd = expect float(level.nv.roundEndTime - Time())
	else
		gs.timeEnd = expect float(level.nv.gameEndTime - Time())
    return gs
}