bool CMapInfoPacket::Write ( NetBitStreamInterface& BitStream ) const { // Write the map weather BitStream.Write ( m_ucWeather ); BitStream.Write ( m_ucWeatherBlendingTo ); BitStream.Write ( m_ucBlendedWeatherHour ); BitStream.WriteBit ( m_bHasSkyGradient ); if ( m_bHasSkyGradient ) { BitStream.Write ( m_ucSkyGradientTR ); BitStream.Write ( m_ucSkyGradientTG ); BitStream.Write ( m_ucSkyGradientTB ); BitStream.Write ( m_ucSkyGradientBR ); BitStream.Write ( m_ucSkyGradientBG ); BitStream.Write ( m_ucSkyGradientBB ); } // Write heat haze BitStream.WriteBit ( m_bHasHeatHaze ); if ( m_bHasHeatHaze ) { SHeatHazeSync heatHaze ( m_HeatHazeSettings ); BitStream.Write ( &heatHaze ); } // Write the map hour BitStream.Write ( m_ucClockHour ); BitStream.Write ( m_ucClockMin ); BitStream.WriteCompressed ( m_ulMinuteDuration ); // Write the map flags SMapInfoFlagsSync flags; flags.data.bShowNametags = m_bShowNametags; flags.data.bShowRadar = m_bShowRadar; flags.data.bCloudsEnabled = m_bCloudsEnabled; BitStream.Write ( &flags ); // Write any other world conditions BitStream.Write ( m_fGravity ); if ( m_fGameSpeed == 1.0f ) BitStream.WriteBit ( true ); else { BitStream.WriteBit ( false ); BitStream.Write ( m_fGameSpeed ); } BitStream.Write ( m_fWaveHeight ); // Write world water level BitStream.Write ( m_WorldWaterLevelInfo.fSeaLevel ); BitStream.WriteBit ( m_WorldWaterLevelInfo.bNonSeaLevelSet ); if ( m_WorldWaterLevelInfo.bNonSeaLevelSet ) BitStream.Write ( m_WorldWaterLevelInfo.fNonSeaLevel ); BitStream.WriteCompressed ( m_usFPSLimit ); // Write the garage states for ( unsigned char i = 0 ; i < MAX_GARAGES ; i++ ) { const SGarageStates& garageStates = *m_pGarageStates; BitStream.WriteBit( garageStates[i] ); } // Write the fun bugs state SFunBugsStateSync funBugs; funBugs.data.bQuickReload = g_pGame->IsGlitchEnabled ( CGame::GLITCH_QUICKRELOAD ); funBugs.data.bFastFire = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTFIRE ); funBugs.data.bFastMove = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTMOVE ); funBugs.data.bCrouchBug = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CROUCHBUG ); funBugs.data.bCloseRangeDamage = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CLOSEDAMAGE ); funBugs.data2.bHitAnim = g_pGame->IsGlitchEnabled ( CGame::GLITCH_HITANIM ); funBugs.data3.bFastSprint = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTSPRINT ); BitStream.Write ( &funBugs ); BitStream.Write ( m_fJetpackMaxHeight ); BitStream.WriteBit ( m_bOverrideWaterColor ); if ( m_bOverrideWaterColor ) { BitStream.Write ( m_ucWaterRed ); BitStream.Write ( m_ucWaterGreen ); BitStream.Write ( m_ucWaterBlue ); BitStream.Write ( m_ucWaterAlpha ); } // Interior sounds BitStream.WriteBit ( m_bInteriorSoundsEnabled ); // Rain level BitStream.WriteBit ( m_bOverrideRainLevel ); if ( m_bOverrideRainLevel ) { BitStream.Write ( m_fRainLevel ); } // Moon size if ( BitStream.Version () >= 0x40 ) { BitStream.WriteBit ( m_bOverrideMoonSize ); if ( m_bOverrideMoonSize ) { BitStream.Write ( m_iMoonSize ); } } // Sun size BitStream.WriteBit ( m_bOverrideSunSize ); if ( m_bOverrideSunSize ) { BitStream.Write ( m_fSunSize ); } // Sun color BitStream.WriteBit ( m_bOverrideSunColor ); if ( m_bOverrideSunColor ) { BitStream.Write ( m_ucSunCoreR ); BitStream.Write ( m_ucSunCoreG ); BitStream.Write ( m_ucSunCoreB ); BitStream.Write ( m_ucSunCoronaR ); BitStream.Write ( m_ucSunCoronaG ); BitStream.Write ( m_ucSunCoronaB ); } // Wind velocity BitStream.WriteBit ( m_bOverrideWindVelocity ); if ( m_bOverrideWindVelocity ) { BitStream.Write ( m_fWindVelX ); BitStream.Write ( m_fWindVelY ); BitStream.Write ( m_fWindVelZ ); } // Far clip distance BitStream.WriteBit ( m_bOverrideFarClipDistance ); if ( m_bOverrideFarClipDistance ) { BitStream.Write ( m_fFarClip ); } // Fog distance BitStream.WriteBit ( m_bOverrideFogDistance ); if ( m_bOverrideFogDistance ) { BitStream.Write ( m_fFogDistance ); } BitStream.Write ( m_fAircraftMaxHeight ); if ( BitStream.Version () >= 0x3E ) BitStream.Write ( m_fAircraftMaxVelocity ); if ( BitStream.Version () >= 0x30 ) { for (int i = WEAPONTYPE_BRASSKNUCKLE; i < WEAPONTYPE_PISTOL; i++) { bool bEnabled; bEnabled = g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ); BitStream.WriteBit ( bEnabled ); } } for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_EXTINGUISHER;i++) { sWeaponPropertySync WeaponProperty; CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i ); BitStream.WriteBit ( true ); WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType(); WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy(); WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed(); WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange(); WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange(); WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo(); WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit(); WeaponProperty.data.nFlags = pWeaponStat->GetFlags(); WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart(); WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop(); WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime(); WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart(); WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop(); WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime(); WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime(); BitStream.Write( &WeaponProperty ); if ( BitStream.Version () >= 0x30 ) { BitStream.WriteBit ( g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ) ); } } for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_TEC9;i++) { sWeaponPropertySync WeaponProperty; BitStream.WriteBit ( true ); for (int j = 0; j <= 2;j++) { CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i, (eWeaponSkill)j ); WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType(); WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy(); WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed(); WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange(); WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange(); WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo(); WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit(); WeaponProperty.data.nFlags = pWeaponStat->GetFlags(); WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart(); WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop(); WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime(); WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart(); WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop(); WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime(); WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime(); BitStream.Write( &WeaponProperty ); } if ( BitStream.Version () >= 0x36 ) { BitStream.WriteBit ( g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ) ); } } if ( BitStream.Version () >= 0x30 ) { for (int i = WEAPONTYPE_CAMERA; i <= WEAPONTYPE_PARACHUTE; i++) { bool bEnabled; bEnabled = g_pGame->GetJetpackWeaponEnabled ( (eWeaponType) i ); BitStream.WriteBit ( bEnabled ); } } multimap< unsigned short, CBuildingRemoval* >::const_iterator iter = g_pGame->GetBuildingRemovalManager ( )->IterBegin(); for (; iter != g_pGame->GetBuildingRemovalManager ( )->IterEnd();++iter) { CBuildingRemoval * pBuildingRemoval = (*iter).second; BitStream.WriteBit( true ); BitStream.Write( pBuildingRemoval->GetModel ( ) ); BitStream.Write( pBuildingRemoval->GetRadius ( ) ); BitStream.Write( pBuildingRemoval->GetPosition ( ).fX ); BitStream.Write( pBuildingRemoval->GetPosition ( ).fY ); BitStream.Write( pBuildingRemoval->GetPosition ( ).fZ ); if ( BitStream.Version() >= 0x039 ) { BitStream.Write ( pBuildingRemoval->GetInterior ( ) ); } } BitStream.WriteBit( false ); if ( BitStream.Version () >= 0x25 ) { bool bOcclusionsEnabled = g_pGame->GetOcclusionsEnabled (); BitStream.WriteBit( bOcclusionsEnabled ); } return true; }
bool CMapInfoPacket::Write ( NetBitStreamInterface& BitStream ) const { // Write the map weather BitStream.Write ( m_ucWeather ); BitStream.Write ( m_ucWeatherBlendingTo ); BitStream.Write ( m_ucBlendedWeatherHour ); BitStream.WriteBit ( m_bHasSkyGradient ); if ( m_bHasSkyGradient ) { BitStream.Write ( m_ucSkyGradientTR ); BitStream.Write ( m_ucSkyGradientTG ); BitStream.Write ( m_ucSkyGradientTB ); BitStream.Write ( m_ucSkyGradientBR ); BitStream.Write ( m_ucSkyGradientBG ); BitStream.Write ( m_ucSkyGradientBB ); } // Write heat haze BitStream.WriteBit ( m_bHasHeatHaze ); if ( m_bHasHeatHaze ) { SHeatHazeSync heatHaze ( m_HeatHazeSettings ); BitStream.Write ( &heatHaze ); } // Write the map hour BitStream.Write ( m_ucClockHour ); BitStream.Write ( m_ucClockMin ); BitStream.WriteCompressed ( m_ulMinuteDuration ); // Write the map flags SMapInfoFlagsSync flags; flags.data.bShowNametags = m_bShowNametags; flags.data.bShowRadar = m_bShowRadar; flags.data.bCloudsEnabled = m_bCloudsEnabled; BitStream.Write ( &flags ); // Write any other world conditions BitStream.Write ( m_fGravity ); if ( m_fGameSpeed == 1.0f ) BitStream.WriteBit ( true ); else { BitStream.WriteBit ( false ); BitStream.Write ( m_fGameSpeed ); } BitStream.Write ( m_fWaveHeight ); // Write world water level BitStream.Write ( m_WorldWaterLevelInfo.fSeaLevel ); BitStream.WriteBit ( m_WorldWaterLevelInfo.bNonSeaLevelSet ); if ( m_WorldWaterLevelInfo.bNonSeaLevelSet ) BitStream.Write ( m_WorldWaterLevelInfo.fNonSeaLevel ); BitStream.WriteCompressed ( m_usFPSLimit ); // Write the garage states for ( unsigned char i = 0 ; i < MAX_GARAGES ; i++ ) { BitStream.WriteBit( static_cast < unsigned char > ( m_pbGarageStates[i] ) ); } // Write the fun bugs state SFunBugsStateSync funBugs; funBugs.data.bQuickReload = g_pGame->IsGlitchEnabled ( CGame::GLITCH_QUICKRELOAD ); funBugs.data.bFastFire = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTFIRE ); funBugs.data.bFastMove = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTMOVE ); funBugs.data.bCrouchBug = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CROUCHBUG ); funBugs.data.bCloseRangeDamage = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CLOSEDAMAGE ); BitStream.Write ( &funBugs ); BitStream.Write ( m_fJetpackMaxHeight ); BitStream.WriteBit ( m_bOverrideWaterColor ); if ( m_bOverrideWaterColor ) { BitStream.Write ( m_ucWaterRed ); BitStream.Write ( m_ucWaterGreen ); BitStream.Write ( m_ucWaterBlue ); BitStream.Write ( m_ucWaterAlpha ); } // Interior sounds BitStream.WriteBit ( m_bInteriorSoundsEnabled ); // Rain level BitStream.WriteBit ( m_bOverrideRainLevel ); if ( m_bOverrideRainLevel ) { BitStream.Write ( m_fRainLevel ); } // Sun size BitStream.WriteBit ( m_bOverrideSunSize ); if ( m_bOverrideSunSize ) { BitStream.Write ( m_fSunSize ); } // Sun color BitStream.WriteBit ( m_bOverrideSunColor ); if ( m_bOverrideSunColor ) { BitStream.Write ( m_ucSunCoreR ); BitStream.Write ( m_ucSunCoreG ); BitStream.Write ( m_ucSunCoreB ); BitStream.Write ( m_ucSunCoronaR ); BitStream.Write ( m_ucSunCoronaG ); BitStream.Write ( m_ucSunCoronaB ); } // Wind velocity BitStream.WriteBit ( m_bOverrideWindVelocity ); if ( m_bOverrideWindVelocity ) { BitStream.Write ( m_fWindVelX ); BitStream.Write ( m_fWindVelY ); BitStream.Write ( m_fWindVelZ ); } // Far clip distance BitStream.WriteBit ( m_bOverrideFarClipDistance ); if ( m_bOverrideFarClipDistance ) { BitStream.Write ( m_fFarClip ); } // Fog distance BitStream.WriteBit ( m_bOverrideFogDistance ); if ( m_bOverrideFogDistance ) { BitStream.Write ( m_fFogDistance ); } BitStream.Write ( m_fAircraftMaxHeight ); for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_EXTINGUISHER;i++) { sWeaponPropertySync WeaponProperty; CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i ); BitStream.WriteBit ( true ); WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType(); WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy(); WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed(); WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange(); WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange(); WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo(); WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit(); WeaponProperty.data.nFlags = pWeaponStat->GetFlags(); WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart(); WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop(); WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime(); WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart(); WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop(); WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime(); WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime(); BitStream.Write( &WeaponProperty ); } for (int i = WEAPONTYPE_PISTOL;i <= WEAPONTYPE_TEC9;i++) { sWeaponPropertySync WeaponProperty; BitStream.WriteBit ( true ); for (int j = 0; j <= 2;j++) { CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager ()->GetWeaponStats( (eWeaponType)i, (eWeaponSkill)j ); WeaponProperty.data.weaponType = (int)pWeaponStat->GetWeaponType(); WeaponProperty.data.fAccuracy = pWeaponStat->GetAccuracy(); WeaponProperty.data.fMoveSpeed = pWeaponStat->GetMoveSpeed(); WeaponProperty.data.fTargetRange = pWeaponStat->GetTargetRange(); WeaponProperty.data.fWeaponRange = pWeaponStat->GetWeaponRange(); WeaponProperty.data.nAmmo = pWeaponStat->GetMaximumClipAmmo(); WeaponProperty.data.nDamage = pWeaponStat->GetDamagePerHit(); WeaponProperty.data.nFlags = pWeaponStat->GetFlags(); WeaponProperty.data.anim_loop_start = pWeaponStat->GetWeaponAnimLoopStart(); WeaponProperty.data.anim_loop_stop = pWeaponStat->GetWeaponAnimLoopStop(); WeaponProperty.data.anim_loop_bullet_fire = pWeaponStat->GetWeaponAnimLoopFireTime(); WeaponProperty.data.anim2_loop_start = pWeaponStat->GetWeaponAnim2LoopStart(); WeaponProperty.data.anim2_loop_stop = pWeaponStat->GetWeaponAnim2LoopStop(); WeaponProperty.data.anim2_loop_bullet_fire = pWeaponStat->GetWeaponAnim2LoopFireTime(); WeaponProperty.data.anim_breakout_time = pWeaponStat->GetWeaponAnimBreakoutTime(); BitStream.Write( &WeaponProperty ); } } return true; }
void CNametags::DrawFromAim() { unsigned long ulCurrentTime = CClientTime::GetTime(); // Got any players that are not local? if (m_pPlayerManager->Count() > 1) { // Grab the local player CClientPlayer* pLocalPlayer = m_pPlayerManager->GetLocalPlayer(); if (pLocalPlayer) { // Grab the current time and the camera unsigned long ulCurrentTime = CClientTime::GetTime(); CCamera* pCamera = g_pGame->GetCamera(); // Grab our controller state CControllerState State; g_pGame->GetPad()->GetCurrentControllerState(&State); // Grab our current weapon slot. Use screen center if melee or none CVector vecStart; CVector vecTarget; eWeaponSlot eSlot = pLocalPlayer->GetCurrentWeaponSlot(); if (eSlot == WEAPONSLOT_TYPE_UNARMED || eSlot == WEAPONSLOT_TYPE_MELEE || eSlot == WEAPONSLOT_TYPE_RIFLE || eSlot == WEAPONSLOT_TYPE_THROWN || eSlot == WEAPONSLOT_TYPE_SPECIAL || eSlot == WEAPONSLOT_TYPE_GIFT || eSlot == WEAPONSLOT_TYPE_PARACHUTE || eSlot == WEAPONSLOT_TYPE_DETONATOR) { // Grab the active cam CCamera* pCamera = g_pGame->GetCamera(); CCam* pActive = pCamera->GetCam(pCamera->GetActiveCam()); // Grab the camera matrix CMatrix matCamera; pCamera->GetMatrix(&matCamera); vecStart = matCamera.vPos; // Range float fRange; eWeaponType eWeapon = pLocalPlayer->GetCurrentWeaponType(); float fSkill = pLocalPlayer->GetStat(g_pGame->GetStats()->GetSkillStatIndex(eWeapon)); CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager()->GetWeaponStatsFromSkillLevel(eWeapon, fSkill); if (pWeaponStat) { fRange = pWeaponStat->GetTargetRange(); } else { fRange = MELEE_VISIBLE_RANGE; } // Find the target position CVector vecFront = *pActive->GetFront(); vecFront.Normalize(); vecTarget = *pActive->GetSource() + vecFront * fRange; } else { // Grab the weapon and keysync state. If it exists and he holds Target down CWeapon* pPlayerWeapon = pLocalPlayer->GetWeapon(); if (pPlayerWeapon && State.RightShoulder1) { // Grab the gun muzzle position eWeaponType eWeapon = pLocalPlayer->GetCurrentWeaponType(); float fSkill = pLocalPlayer->GetStat(g_pGame->GetStats()->GetSkillStatIndex(eWeapon)); CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager()->GetWeaponStatsFromSkillLevel(eWeapon, fSkill); CVector vecGunMuzzle = *pWeaponStat->GetFireOffset(); pLocalPlayer->GetTransformedBonePosition(BONE_RIGHTWRIST, vecGunMuzzle); // Grab the target point pCamera->Find3rdPersonCamTargetVector(AIM_VISIBLE_RANGE, &vecGunMuzzle, &vecStart, &vecTarget); } else { // Grab the active cam CCam* pActive = pCamera->GetCam(pCamera->GetActiveCam()); // Grab the camera matrix CMatrix matCamera; pCamera->GetMatrix(&matCamera); vecStart = matCamera.vPos; // Find the target position CVector vecFront = *pActive->GetFront(); vecFront.Normalize(); vecTarget = *pActive->GetSource() + vecFront * MELEE_VISIBLE_RANGE; } } // Ignore the local player for this pLocalPlayer->WorldIgnore(true); // Do the raycast CColPoint* pColPoint = NULL; CEntity* pEntity = NULL; SLineOfSightFlags flags; flags.bCheckBuildings = true; flags.bCheckVehicles = true; flags.bCheckPeds = true; flags.bCheckObjects = true; flags.bCheckDummies = true; flags.bSeeThroughStuff = true; flags.bIgnoreSomeObjectsForCamera = false; flags.bShootThroughStuff = true; g_pGame->GetWorld()->ProcessLineOfSight(&vecStart, &vecTarget, &pColPoint, &pEntity, flags); if (pColPoint) pColPoint->Destroy(); // Un-ignore the local player pLocalPlayer->WorldIgnore(false); // Did we find an entity? if (pEntity) { // Grab the CClientEntity belonging to this game_sa entity CClientEntity* pClientEntity = reinterpret_cast<CClientEntity*>(pEntity->GetStoredPointer()); if (pClientEntity) { // Is it a vehicle? Is it a ped? eClientEntityType EntityType = pClientEntity->GetType(); if (EntityType == CCLIENTVEHICLE) { CClientVehicle* pClientVehicle = static_cast<CClientVehicle*>(pClientEntity); // Set the current time as the last draw time for all players inside CClientPed* pPed; int i; for (i = 0; i < 8; i++) { // Grab this seat's occupant and set its last nametag show time to now pPed = pClientVehicle->GetOccupant(i); if (pPed && pPed->GetType() == CCLIENTPLAYER) { static_cast<CClientPlayer*>(pPed)->SetLastNametagShow(ulCurrentTime); } } } else if (EntityType == CCLIENTPLAYER) { // Grab the player this entity is CClientPlayer* pClientPlayer = static_cast<CClientPlayer*>(pClientEntity); if (pClientPlayer) { // Set now as the last time we had the cursor above him pClientPlayer->SetLastNametagShow(ulCurrentTime); } } } } // Grab the local player vehicle CClientVehicle* pLocalVehicle = pLocalPlayer->GetOccupiedVehicle(); // Draw the nametags we need to CClientPlayer* pPlayer; CClientStreamElement* pElement; list<CClientStreamElement*>::const_iterator iter = m_pPlayerStreamer->ActiveElementsBegin(); for (; iter != m_pPlayerStreamer->ActiveElementsEnd(); ++iter) { pElement = *iter; if (!pElement->IsStreamedIn()) continue; if (pElement->GetType() != CCLIENTPLAYER) continue; pPlayer = static_cast<CClientPlayer*>(pElement); if (pPlayer->IsLocalPlayer()) continue; // Is he in the same vehicle as the local player? if (pLocalVehicle && pPlayer->GetOccupiedVehicle() == pLocalVehicle) { pPlayer->SetLastNametagShow(ulCurrentTime); } // Can we show this player's nametag unsigned long ulLastNametagShow = pPlayer->GetLastNametagShow(); if (ulLastNametagShow != 0 && ulCurrentTime <= ulLastNametagShow + NAMETAG_END_FADE_TIME) { unsigned long ulLastNametagShow = pPlayer->GetLastNametagShow(); // Calculate the alpha modifier float fAlphaTimeModifier; if (ulCurrentTime < ulLastNametagShow + NAMETAG_BEGIN_FADE_TIME) { fAlphaTimeModifier = 1.0f; } else { fAlphaTimeModifier = 1.0f - (ulCurrentTime - ulLastNametagShow - NAMETAG_BEGIN_FADE_TIME) / 1000.0f; } // Calculate the alpha for the nametag unsigned char ucAlpha = static_cast<unsigned char>(180.0f * fAlphaTimeModifier); // Draw it DrawTagForPlayer(pPlayer, ucAlpha); } } } } }