//----------------------------------------------------------------------------- // Purpose: Draw function for the element //----------------------------------------------------------------------------- void CHUDBlockHealth::Paint() { wchar_t sIDString[ MAX_ID_STRING ]; sIDString[0] = 0; m_bBlockInTarget = false; C_BaseEntity *pEntity = ProcessTarget(); // Did we find a target? if ( pEntity ) { // Is it a block? if ( pEntity->IsBlock() && pEntity->GetHealth() > 0 ) { C_BlockBase *pBlock = static_cast< C_BlockBase * > ( pEntity ); Color c = GetTeamColor( pBlock->GetTeamNumber() ); float BlockHealth = pBlock->GetHealth(); float MaxBlockHealth = pBlock->GetMaxHealth(); float HealthRatio = ( BlockHealth / MaxBlockHealth ) * 100; wchar_t wszHealthText[ 10 ]; unsigned int HealthTextLen = ARRAYSIZE( wszHealthText ); _snwprintf( wszHealthText, HealthTextLen - 1, L"%.0f%%", HealthRatio ); wszHealthText[ HealthTextLen - 1 ] = '\0'; wchar_t *printFormatString = NULL; printFormatString = L"Health | %s1 |"; g_pVGuiLocalize->ConstructString( sIDString, sizeof( sIDString ), printFormatString, 1, wszHealthText ); // Check if we have anything to output if ( sIDString[0] ) { int wide, tall; vgui::surface()->GetTextSize( m_hFont, sIDString, wide, tall ); int ypos = YRES(260); int xpos = (ScreenWidth() - wide) / 2; vgui::surface()->DrawSetTextFont( m_hFont ); vgui::surface()->DrawSetTextPos( xpos, ypos ); vgui::surface()->DrawSetTextColor( c ); vgui::surface()->DrawPrintText( sIDString, wcslen(sIDString) ); } } } }
void CC_FreezeStatus( const CCommand& args ) { C_BaseEntity *pEntity = ProcessTarget(); // Did we find a target? if ( pEntity ) { // Is it a block? if ( pEntity->IsBlock() && pEntity->GetHealth() > 0 ) { C_BlockBase *pBlock = static_cast< C_BlockBase * > ( pEntity ); if ( ClassicGameRules() ) { int frozenplayerindex = engine->GetPlayerForUserID( pBlock->GetLastFrozenByUserID() ); C_BasePlayer *pPlayer = UTIL_PlayerByIndex( frozenplayerindex ); if ( pPlayer ) { Msg( "\tFrozen by %s\n", pPlayer->GetPlayerName() ); } else { Msg( "\tFrozen by WORLD\n" ); } int unfrozenplayerindex = engine->GetPlayerForUserID( pBlock->GetLastUnFrozenByUserID() ); pPlayer = UTIL_PlayerByIndex( unfrozenplayerindex ); if ( pPlayer ) { Msg( "\tUnFrozen by %s\n", pPlayer->GetPlayerName() ); } else { Msg( "\tUnFrozen by WORLD\n" ); } } } } }