//-----------------------------------------------------------------------------
// Purpose: Updates information about teams
//-----------------------------------------------------------------------------
void CTFDeathMatchScoreBoardDialog::UpdateTeamInfo()
{
	// update the team sections in the scoreboard
	for (int teamIndex = TF_TEAM_RED; teamIndex <= TF_TEAM_YELLOW; teamIndex++)
	{
		wchar_t *teamName = NULL;
		C_Team *team = GetGlobalTeam( teamIndex );
		if ( team )
		{
			// choose dialog variables to set depending on team
			const char *pDialogVarTeamScore = NULL;
			const char *pDialogVarTeamPlayerCount = NULL;
			const char *pDialogVarTeamName = NULL;
			switch ( teamIndex ) 
			{
				case TF_TEAM_RED:
					pDialogVarTeamScore = "redteamscore";
					pDialogVarTeamPlayerCount = "redteamplayercount";
					pDialogVarTeamName = "redteamname";
					break;
				default:
					Assert( false );
					break;
			}

			// update # of players on each team
			wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];
			_snwprintf( wNumPlayers, ARRAYSIZE( wNumPlayers ), L"%i", team->Get_Number_Players() );
			if ( !teamName && team )
			{
				g_pVGuiLocalize->ConvertANSIToUnicode( team->Get_Name(), name, sizeof( name ) );
				teamName = name;
			}
			if ( team->Get_Number_Players() == 1 )
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#TF_ScoreBoard_Player" ), 1, wNumPlayers );
			}
			else
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#TF_ScoreBoard_Players" ), 1, wNumPlayers );
			}

			// set # of players for team in dialog
			SetDialogVariable( pDialogVarTeamPlayerCount, string1 );

			// set team score in dialog
			SetDialogVariable( pDialogVarTeamScore, team->Get_Score() );		

			// set team name
			SetDialogVariable( pDialogVarTeamName, team->Get_Name() );
		}
	}
}
const char * C_PlayerResource::GetTeamName(int index)
{
	C_Team *team = GetGlobalTeam( index );

	if ( !team )
		return "Unknown";

	return team->Get_Name();
}
示例#3
0
void CHudDHLRoundTime::MsgFunc_RoundEnd( bf_read &msg )
{
	bool bSuccess = false;
	byte val = msg.ReadByte();
	if ( val == 255 ) //Arbitrary "round draw" value
	{
		wcsncpy( wszHudText, g_pVGuiLocalize->Find( "#DHL_ROUND_DRAW" ), 50 );
		bSuccess = true;
	}
	else
	{
		if ( DHLRules()->IsTeamplay() )
		{
			//Val indicates winning team #
			C_Team* pTeam = GetGlobalTeam( val );
			if ( pTeam )
			{
				wchar_t wszTeamName[32];
				g_pVGuiLocalize->ConvertANSIToUnicode( pTeam->Get_Name(), wszTeamName, sizeof(wszTeamName) );
				g_pVGuiLocalize->ConstructString( wszHudText, sizeof( wszHudText ), g_pVGuiLocalize->Find( "#DHL_ROUNDPLAY_WINNER" ), 1, wszTeamName );
				bSuccess = true;
			}
		}
		else
		{
			//Val indicates winning player's index
			C_BasePlayer *pPlayer = UTIL_PlayerByIndex( val );
			if ( pPlayer )
			{
				wchar_t wszPlayerName[MAX_PLAYER_NAME_LENGTH];
				g_pVGuiLocalize->ConvertANSIToUnicode( pPlayer->GetPlayerName(), wszPlayerName, sizeof(wszPlayerName) );
				g_pVGuiLocalize->ConstructString( wszHudText, sizeof( wszHudText ), g_pVGuiLocalize->Find( "#DHL_LMS_WINNER" ), 1, wszPlayerName );
				bSuccess = true;
			}
		}
	}

	static ConVarRef restartDelay( "dhl_roundrestartdelay" );
	if ( bSuccess )
		flHudTextTime = gpGlobals->curtime + restartDelay.GetFloat();
}
//-----------------------------------------------------------------------------
// Purpose: Updates information about teams
//-----------------------------------------------------------------------------
void CHL2MPClientScoreBoardDialog::UpdateTeamInfo()
{
	// update the team sections in the scoreboard
	int startTeam = TEAM_UNASSIGNED;

	if ( HL2MPRules()->IsTeamplay() )
		startTeam = TEAM_COMBINE;

	for ( int teamIndex = startTeam; teamIndex <= TEAM_REBELS; teamIndex++ )
	{
		// Make sure spectator is always skipped here.
		if ( teamIndex == TEAM_SPECTATOR )
			continue;

		wchar_t *teamName = NULL;
		C_Team *team = GetGlobalTeam( teamIndex );
		if ( team )
		{
			// choose dialog variables to set depending on team
			const char *pDialogVarTeamScore = NULL;
			const char *pDialogVarTeamPlayerCount = NULL;
			const char *pDialogVarTeamPing = NULL;
			switch ( teamIndex ) 
			{
				case TEAM_REBELS:
					teamName = g_pVGuiLocalize->Find( "#HL2MP_ScoreBoard_Rebels" );
					pDialogVarTeamScore = "r_teamscore";
					pDialogVarTeamPlayerCount = "r_teamplayercount";
					pDialogVarTeamPing = "r_teamping";
					break;
				case TEAM_COMBINE:
					teamName = g_pVGuiLocalize->Find( "#HL2MP_ScoreBoard_Combine" );
					pDialogVarTeamScore = "c_teamscore";
					pDialogVarTeamPlayerCount = "c_teamplayercount";
					pDialogVarTeamPing = "c_teamping";
					break;
				case TEAM_UNASSIGNED:
					teamName = g_pVGuiLocalize->Find( "#HL2MP_ScoreBoard_DM" );
					pDialogVarTeamPlayerCount = "dm_playercount";
					pDialogVarTeamPing = "dm_ping";
					break;
				default:
					Assert( false );
					break;
			}

			// update # of players on each team
			wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];
			_snwprintf( wNumPlayers, ARRAYSIZE( wNumPlayers ), L"%i", team->Get_Number_Players() );
			if ( !teamName && team )
			{
				g_pVGuiLocalize->ConvertANSIToUnicode( team->Get_Name(), name, sizeof( name ) );
				teamName = name;
			}
			if ( team->Get_Number_Players() == 1 )
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#ScoreBoard_Player" ), 2, teamName, wNumPlayers );
			}
			else
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#ScoreBoard_Players" ), 2, teamName, wNumPlayers );
			}

			// set # of players for team in dialog
			SetDialogVariable( pDialogVarTeamPlayerCount, string1 );

			// set team score in dialog
			if ( teamIndex != TEAM_UNASSIGNED )	// Don't accumulate deathmatch scores.
				SetDialogVariable( pDialogVarTeamScore, team->Get_Score() );			

			int pingsum = 0;
			int numcounted = 0;
			for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ )
			{
				if( g_PR->IsConnected( playerIndex ) && g_PR->GetTeam( playerIndex ) == teamIndex )
				{
					int ping = g_PR->GetPing( playerIndex );

					if ( ping >= 1 )
					{
						pingsum += ping;
						numcounted++;
					}
				}
			}

			if ( numcounted > 0 )
			{
				int ping = (int)( (float)pingsum / (float)numcounted );
				SetDialogVariable( pDialogVarTeamPing, ping );		
			}
			else
			{
				SetDialogVariable( pDialogVarTeamPing, "" );	
			}
		}
	}
}
示例#5
0
//-----------------------------------------------------------------------------
// Purpose: resets the scoreboard team info
//-----------------------------------------------------------------------------
void CHL2MPClientScoreBoardDialog::UpdateTeamInfo()
{
	IGameResources *gr = GameResources();
	if ( !gr )
		return;

	int iNumPlayersInGame = 0;

	for ( int j = 1; j <= gpGlobals->maxClients; j++ )
	{	
		if ( g_PR->IsConnected( j ) )
		{
			iNumPlayersInGame++;
		}
	}

	// update the team sections in the scoreboard
	for ( int i = TEAM_SPECTATOR; i < TEAM_MAXCOUNT; i++ )
	{
		wchar_t *teamName = NULL;
		int sectionID = 0;
		C_Team *team = GetGlobalTeam(i);

		if ( team )
		{
			sectionID = GetSectionFromTeamNumber( i );
	
			// update team name
			wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];

			if ( HL2MPRules()->IsTeamplay() == false )
			{
				_snwprintf( wNumPlayers, ARRAYSIZE(wNumPlayers), L"%i", iNumPlayersInGame );
#ifdef WIN32
				_snwprintf( name, ARRAYSIZE(name), L"%s", g_pVGuiLocalize->Find("#ScoreBoard_Deathmatch") );
#else
				_snwprintf( name, ARRAYSIZE(name), L"%S", g_pVGuiLocalize->Find("#ScoreBoard_Deathmatch") );
#endif
				
				teamName = name;

				if ( iNumPlayersInGame == 1)
				{
					g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Player"), 2, teamName, wNumPlayers );
				}
				else
				{
					g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Players"), 2, teamName, wNumPlayers );
				}
			}
			else
			{
				_snwprintf(wNumPlayers, ARRAYSIZE(wNumPlayers), L"%i", team->Get_Number_Players());

				if (!teamName && team)
				{
					g_pVGuiLocalize->ConvertANSIToUnicode(team->Get_Name(), name, sizeof(name));
					teamName = name;
				}

				if (team->Get_Number_Players() == 1)
				{
					g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Player"), 2, teamName, wNumPlayers );
				}
				else
				{
					g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Players"), 2, teamName, wNumPlayers );
				}

				// update stats
				wchar_t val[6];
				V_snwprintf(val, ARRAYSIZE(val), L"%d", team->Get_Score());
				m_pPlayerList->ModifyColumn(sectionID, "frags", val);
				if (team->Get_Ping() < 1)
				{
					m_pPlayerList->ModifyColumn(sectionID, "ping", L"");
				}
				else
				{
					V_snwprintf(val, ARRAYSIZE(val), L"%d", team->Get_Ping());
					m_pPlayerList->ModifyColumn(sectionID, "ping", val);
				}

			}
		
			m_pPlayerList->ModifyColumn(sectionID, "name", string1);
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: resets the scoreboard team info
//-----------------------------------------------------------------------------
void CHL2MPClientScoreBoardDialog::UpdateTeamInfo()
{
	if ( g_PR == NULL )
		return;

	int iNumPlayersInGame = 0;

	for ( int j = 1; j <= gpGlobals->maxClients; j++ )
	{	
		if ( g_PR->IsConnected( j ) )
		{
			iNumPlayersInGame++;
		}
	}

	//BG2 - Get the total team damage points. -HairyPotter
	iAmericanDmg = 0;
	iBritishDmg = 0;
	iSpecDmg = 0;

	for ( int j = 1; j <= gpGlobals->maxClients; j++ )
	{	
		C_BasePlayer *pPlayer = UTIL_PlayerByIndex( j );
		if ( pPlayer )
		{
			switch ( pPlayer->GetTeamNumber() )
			{
			case TEAM_AMERICANS:
				iAmericanDmg += g_PR->GetDeaths( j );
				break;
			case TEAM_BRITISH:
				iBritishDmg += g_PR->GetDeaths( j );
				break;
			case TEAM_SPECTATOR:
				iSpecDmg += g_PR->GetDeaths( j );
			break;
			}
		}
	}
	//

	// update the team sections in the scoreboard
	for ( int i = TEAM_SPECTATOR; i < TEAM_MAXCOUNT; i++ )
	{
		wchar_t *teamName = NULL;
		int sectionID = 0;
		C_Team *team = GetGlobalTeam(i);

		if ( team )
		{
			sectionID = GetSectionFromTeamNumber( i );

			// update team name
			wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];

			_snwprintf(wNumPlayers, 6, L"%i", team->Get_Number_Players());

			if (!teamName && team)
			{
				g_pVGuiLocalize->ConvertANSIToUnicode(team->Get_Name(), name, sizeof(name));
				teamName = name;
			}

			if (team->Get_Number_Players() == 1)
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Player"), 2, teamName, wNumPlayers );
			}
			else
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#ScoreBoard_Players"), 2, teamName, wNumPlayers );
			}

			// update stats
			wchar_t deaths[8];
			wchar_t val[6];
			swprintf(val, L"%d", team->Get_Score());

			switch( i )
			{
				case TEAM_AMERICANS:	
					swprintf(deaths, L"%d", iAmericanDmg);
					break;
				case TEAM_BRITISH:	
					swprintf(deaths, L"%d", iBritishDmg);
					break;
				case TEAM_SPECTATOR:	
					swprintf(deaths, L"%d", iSpecDmg);
					break;
			}

			if ( cl_scoreboard.GetInt() == 1 ) //Old scoreboard.
			{
				m_pPlayerList->ModifyColumn(sectionID, "deaths", deaths);
				m_pPlayerList->ModifyColumn(sectionID, "frags", val);
				if (team->Get_Ping() < 1)
				{
					m_pPlayerList->ModifyColumn(sectionID, "ping", L"");
				}
				else
				{
					swprintf(val, L"%d", team->Get_Ping());
					m_pPlayerList->ModifyColumn(sectionID, "ping", val);
				}
				m_pPlayerList->ModifyColumn(sectionID, "name", string1);
			}
			else //New Scoreboard.
			{
				switch( i )
				{
					case TEAM_BRITISH:	//British is always "sectionID" 1 in new scoreboard, because the british team has their own section.
						//swprintf(deaths, L"%d", iBritishDmg);
						m_pBritishPlayerList->ModifyColumn(1, "deaths", deaths);
						m_pBritishPlayerList->ModifyColumn(1, "frags", val);
						if (team->Get_Ping() < 1)
						{
							m_pBritishPlayerList->ModifyColumn(1, "ping", L"");
						}
						else
						{
							swprintf(val, L"%d", team->Get_Ping());
							m_pBritishPlayerList->ModifyColumn(1, "ping", val);
						}
						m_pBritishPlayerList->ModifyColumn(1, "name", string1);
						break;
					default: //If it's not British just stick everything in the "default" (American) section.
						m_pPlayerList->ModifyColumn(sectionID, "deaths", deaths);
						m_pPlayerList->ModifyColumn(sectionID, "frags", val);
						if (team->Get_Ping() < 1)
						{
							m_pPlayerList->ModifyColumn(sectionID, "ping", L"");
						}
						else
						{
							swprintf(val, L"%d", team->Get_Ping());
							m_pPlayerList->ModifyColumn(sectionID, "ping", val);
						}
						m_pPlayerList->ModifyColumn(sectionID, "name", string1);
						break;
				}
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: Updates information about teams
//-----------------------------------------------------------------------------
void CCSClientScoreBoardDialog::UpdateTeamInfo()
{
	// update the team sections in the scoreboard
	for ( int teamIndex = TEAM_TERRORIST; teamIndex <= TEAM_CT; teamIndex++ )
	{
		wchar_t *teamName = NULL;
		C_Team *team = GetGlobalTeam( teamIndex );
		if ( team )
		{
			// choose dialog variables to set depending on team
			const char *pDialogVarTeamScore = NULL;
			const char *pDialogVarTeamPlayerCount = NULL;
			const char *pDialogVarTeamPing = NULL;
			switch ( teamIndex ) {
				case TEAM_TERRORIST:
					teamName = g_pVGuiLocalize->Find( "#Cstrike_ScoreBoard_Ter" );
					pDialogVarTeamScore = "t_teamscore";
					pDialogVarTeamPlayerCount = "t_teamplayercount";
					pDialogVarTeamPing = "t_teamping";
					break;
				case TEAM_CT:
					teamName = g_pVGuiLocalize->Find( "#Cstrike_ScoreBoard_CT" );
					pDialogVarTeamScore = "ct_teamscore";
					pDialogVarTeamPlayerCount = "ct_teamplayercount";
					pDialogVarTeamPing = "ct_teamping";
					break;
				default:
					Assert( false );
					break;
			}

			// update # of players on each team
			wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];
			_snwprintf( wNumPlayers, ARRAYSIZE( wNumPlayers ), L"%i", team->Get_Number_Players() );
			if ( !teamName && team )
			{
				g_pVGuiLocalize->ConvertANSIToUnicode( team->Get_Name(), name, sizeof( name ) );
				teamName = name;
			}
			if ( team->Get_Number_Players() == 1 )
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#Cstrike_ScoreBoard_Player" ), 2, teamName, wNumPlayers );
			}
			else
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#Cstrike_ScoreBoard_Players" ), 2, teamName, wNumPlayers );
			}

			// set # of players for team in dialog
			SetDialogVariable( pDialogVarTeamPlayerCount, string1 );

			// set team score in dialog
			SetDialogVariable( pDialogVarTeamScore, team->Get_Score() );			

			int pingsum = 0;
			int numcounted = 0;
			for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ )
			{
				if( g_PR->IsConnected( playerIndex ) && g_PR->GetTeam( playerIndex ) == teamIndex )
				{
					int ping = g_PR->GetPing( playerIndex );

					if ( ping >= 1 )
					{
						pingsum += ping;
						numcounted++;
					}
				}
			}

			if ( numcounted > 0 )
			{
				int ping = (int)( (float)pingsum / (float)numcounted );
				SetDialogVariable( pDialogVarTeamPing, ping );		
			}
			else
			{
				SetDialogVariable( pDialogVarTeamPing, "" );	
			}
		}
	}
}
示例#8
0
//-----------------------------------------------------------------------------
// Purpose: resets the scoreboard team info
//-----------------------------------------------------------------------------
void CHL2WarsScoreboard::UpdateTeamInfo()
{
	if ( GameResources() == NULL )
		return;

	int iNumPlayersInGame = 0;

	for ( int j = 1; j <= gpGlobals->maxClients; j++ )
	{	
		if ( GameResources()->IsConnected( j ) )
		{
			iNumPlayersInGame++;
		}
	}

	// update the team sections in the scoreboard
	for ( int i = TEAM_UNASSIGNED; i < TEAM_MAXCOUNT; i++ )
	{
		wchar_t *teamName = NULL;
		int sectionID = 0;
		C_Team *team = GetGlobalTeam(i);

		sectionID = GetSectionFromTeamNumber( i );
		if ( team && HL2WarsGameRules()->IsTeamplay() == true )
		{
			// update team name
			wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];

			_snwprintf(wNumPlayers, 6, L"%i", team->Get_Number_Players());

			if (!teamName && team)
			{
				g_pVGuiLocalize->ConvertANSIToUnicode(team->Get_Name(), name, sizeof(name));
				teamName = name;
			}

			if (team->Get_Number_Players() == 1)
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Player"), 2, teamName, wNumPlayers );
			}
			else
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Players"), 2, teamName, wNumPlayers );
			}

			// update stats
			wchar_t val[6];
			swprintf(val, L"%d", team->Get_Score());
			m_pPlayerList->ModifyColumn(sectionID, "frags", val);
			if (team->Get_Ping() < 1)
			{
				m_pPlayerList->ModifyColumn(sectionID, "ping", L"");
			}
			else
			{
				swprintf(val, L"%d", team->Get_Ping());
				m_pPlayerList->ModifyColumn(sectionID, "ping", val);
			}
		
			m_pPlayerList->ModifyColumn(sectionID, "name", string1);
		}
		else
		{
			// update team name
			//wchar_t name[64];
			wchar_t string1[1024];
			wchar_t wNumPlayers[6];

			_snwprintf(wNumPlayers, 6, L"%i", iNumPlayersInGame );
			//_snwprintf( name, sizeof(name), L"%s", g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Player") );
			
			//teamName = name;

			if ( iNumPlayersInGame == 1)
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Player"), 2, wNumPlayers );
			}
			else
			{
				g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find("#HL2Wars_ScoreBoard_Players"), 2, wNumPlayers );
			}

			m_pPlayerList->ModifyColumn(sectionID, "name", string1);
		}
	}
}