Team score not updating on the hud?


(Lanz) #1

Well I’m working on this small mod with a new game mode. The score for each team is important in this game mode and is changed so the team only gets points when they accomplish this objective. So I thought I would add the team scores to the hud. That was easy just added some code like this:


static void CG_DrawTeamScore( void ) {
	char	*s1, *s2;
	if ( cg_gameType.integer != GT_WOLF_PB )
		return;
	
	if ( cg_drawTeamScore.integer != 1 )
		return;

	CG_DrawTeamBackground( 520, 340, 60, 40, 0.5f, TEAM_AXIS );			
	CG_DrawTeamBackground( 580, 340, 60, 40, 0.5f, TEAM_ALLIES );			
	
	s1 = va("%i", cg.teamScores[TEAM_AXIS - TEAM_AXIS] );
	s2 = va("%i", cg.teamScores[TEAM_ALLIES - TEAM_AXIS] );

	CG_DrawStringExt( 530, 343, CG_TranslateString( s1 ), colorWhite, qfalse, qtrue, 15, 35, 0 );
	CG_DrawStringExt( 590, 343, CG_TranslateString( s2 ), colorWhite, qfalse, qtrue, 15, 35, 0 );
}

And sure enough it draws on the hud, but it doesn’t update the score until I looked at the scoreboard. So I checked the code for the scoreboard to try and locate where it actually gets the update of the score but I just can’t find it. Maybe I’m just tired or something (it’s 4.30 am and I need to get up in just a few hours lol) but if anyone could help I would really apreciate it.


(Lanz) #2

Bah a quick nap later (yawn) and I found it.


static void CG_DrawTeamScore( void ) {
	char	*s1, *s2;
	if ( cg_gameType.integer != GT_WOLF_PB )
		return;
	
	if ( cg_drawTeamScore.integer != 1 )
		return;

	if ( cg.scoresRequestTime + 2000 < cg.time ) {
		cg.scoresRequestTime = cg.time;

		if(!cg.demoPlayback && cg.mvTotalClients < 1) trap_SendClientCommand( "score" );
	}

	CG_DrawTeamBackground( 520, 340, 60, 40, 0.5f, TEAM_AXIS );			
	CG_DrawTeamBackground( 580, 340, 60, 40, 0.5f, TEAM_ALLIES );			
	
	s1 = va("%i", cg.teamScores[TEAM_AXIS - TEAM_AXIS] );
	s2 = va("%i", cg.teamScores[TEAM_ALLIES - TEAM_AXIS] );

	CG_DrawStringExt( 530, 343, CG_TranslateString( s1 ), colorWhite, qfalse, qtrue, 15, 35, 0 );
	CG_DrawStringExt( 590, 343, CG_TranslateString( s2 ), colorWhite, qfalse, qtrue, 15, 35, 0 );
}

Hmm, the question now is how much (if any) bandwith trap_SendClientCommand( “score” ) takes… anyone knows?


(digibob) #3

Yowzers, i wouldn’t want to be continually sending score back and forth.

A better idea would be to tuck the team scores into some unused fields on the game_manager entity, this entity is broadcast to all clients, but is delta compressed, so nothing will need to be sent unless something changes. You can find examples of this by seeing how the landmine counts are sent across the network.


(Lanz) #4

lol yeah I suspected that it would be a bad idea, I just couldn’t find any info about it more than a var set on the server that the client wanted some score sent.

Thanks for the help and the tip about the game_manager will take a look.

Lanz (still a q3/et source noob)

Edit: worked like a charm! Thanks.