当前位置: 首页>>代码示例>>C++>>正文


C++ CVehicle::GetHealth方法代码示例

本文整理汇总了C++中CVehicle::GetHealth方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetHealth方法的具体用法?C++ CVehicle::GetHealth怎么用?C++ CVehicle::GetHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CVehicle的用法示例。


在下文中一共展示了CVehicle::GetHealth方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Write

bool CLightsyncPacket::Write(NetBitStreamInterface& BitStream) const
{
    bool bSyncPosition;

    if (Count() == 0)
        return false;

    for (std::vector<CPlayer*>::const_iterator iter = m_players.begin(); iter != m_players.end(); ++iter)
    {
        CPlayer*                       pPlayer = *iter;
        CPlayer::SLightweightSyncData& data = pPlayer->GetLightweightSyncData();
        CVehicle*                      pVehicle = pPlayer->GetOccupiedVehicle();

        // Find the difference between now and the time the position last changed for the player
        long long llTicksDifference = GetTickCount64_() - pPlayer->GetPositionLastChanged();

        // Right we need to sync the position if there is no vehicle or he's in a vehicle and the difference between setPosition is less than or equal to the
        // slow sync rate i.e. make sure his position has been updated more than 0.001f in the last 1500ms plus a small margin for error (probably not needed).
        // This will ensure we only send positions when the position has changed.
        bSyncPosition = (!pVehicle || pPlayer->GetOccupiedVehicleSeat() == 0) && llTicksDifference <= g_TickRateSettings.iLightSync + 100;

        BitStream.Write(pPlayer->GetID());
        BitStream.Write((unsigned char)pPlayer->GetSyncTimeContext());

        unsigned short usLatency = pPlayer->GetPing();
        BitStream.WriteCompressed(usLatency);

        BitStream.WriteBit(data.health.bSync);
        if (data.health.bSync)
        {
            SPlayerHealthSync health;
            health.data.fValue = pPlayer->GetHealth();
            BitStream.Write(&health);

            SPlayerArmorSync armor;
            armor.data.fValue = pPlayer->GetArmor();
            BitStream.Write(&armor);
        }

        BitStream.WriteBit(bSyncPosition);
        if (bSyncPosition)
        {
            SLowPrecisionPositionSync pos;
            pos.data.vecPosition = pPlayer->GetPosition();
            BitStream.Write(&pos);

            bool bSyncVehicleHealth = data.vehicleHealth.bSync && pVehicle;
            BitStream.WriteBit(bSyncVehicleHealth);
            if (bSyncVehicleHealth)
            {
                SLowPrecisionVehicleHealthSync health;
                health.data.fValue = pVehicle->GetHealth();
                BitStream.Write(&health);
            }
        }
    }

    return true;
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:59,代码来源:CLightsyncPacket.cpp

示例2: GetHealth

// getVehicleHealth(vehicleid)
int CVehicleModuleNatives::GetHealth(EntityId vehicleid)
{
    if(g_pVehicleManager->DoesExist(vehicleid))
    {
        CVehicle * pVehicle = g_pVehicleManager->GetAt(vehicleid);

        if(pVehicle)
        {
            return pVehicle->GetHealth();
        }
    }

    return -1;
}
开发者ID:mat27,项目名称:ivmultiplayer,代码行数:15,代码来源:VehicleModuleNatives.cpp

示例3: SendInCarFullSyncData

void CLocalPlayer::SendInCarFullSyncData()
{
	if(m_pPlayerPed)
	{
		RakNet::BitStream bsVehicleSync;
		VEHICLE_SYNC_DATA vehicleSyncData;
		MATRIX4X4 matVehicle;
		CVehicleManager * pVehicleManager = pNetowkManager->GetVehicleManager();
		CVehicle * pGameVehicle = NULL;

		// write packet id
		bsVehicleSync.Write((MessageID)ID_VEHICLE_SYNC);

		vehicleSyncData.vehicleID = pVehicleManager->FindIDFromGtaPtr(m_pPlayerPed->GetGtaVehicle());

		// make sure we have a valid vehicle
		if(vehicleSyncData.vehicleID == INVALID_ENTITY_ID)
		{
			return;
		}

		// get the player keys
		vehicleSyncData.wKeys = m_pPlayerPed->GetKeys();

		// get the vehicle pointer
		pGameVehicle = pVehicleManager->GetAt(vehicleSyncData.vehicleID);

		// make sure the vehicle pointer is valid
		if(!pGameVehicle)
		{
			return;
		}

		// get the vehicle matrix
		pGameVehicle->GetMatrix(&matVehicle);

		// copy the roll and direction vectors
		memcpy(&vehicleSyncData.vecRoll, &matVehicle.vLookRight, sizeof(Vector3));
		memcpy(&vehicleSyncData.vecDirection, &matVehicle.vLookUp, sizeof(Vector3));
		// pack the roll and direction vectors
		//CompressVector1(&matVehicle.vLookRight, &vehicleSyncData.cvecRoll);
		//CompressVector1(&matVehicle.vLookUp, &vehicleSyncData.cvecDirection);

		// copy the vehicle position
		memcpy(&vehicleSyncData.vecPos, &matVehicle.vPos, sizeof(Vector3));

		// get the vehicle move speed
		pGameVehicle->GetMoveSpeed(&vehicleSyncData.vecMoveSpeed);

		// get the vehicle turn speed
		pGameVehicle->GetTurnSpeed(&vehicleSyncData.vecTurnSpeed);

		// pack the vehicle health
		vehicleSyncData.byteVehicleHealth = PACK_VEHICLE_HEALTH(pGameVehicle->GetHealth());

		// get the player health (casted to a byte to save space)
		vehicleSyncData.bytePlayerHealth = (BYTE)m_pPlayerPed->GetHealth();

		// get the player armour (casted to a byte to save space)
		vehicleSyncData.bytePlayerArmour = (BYTE)m_pPlayerPed->GetArmour();

		// write vehicle sync struct to bit stream
		bsVehicleSync.Write((char *)&vehicleSyncData, sizeof(VEHICLE_SYNC_DATA));

		// send sync data
		pNetowkManager->GetRakPeer()->Send(&bsVehicleSync,HIGH_PRIORITY,UNRELIABLE_SEQUENCED,0,UNASSIGNED_SYSTEM_ADDRESS,TRUE);
	}
}
开发者ID:Tonyx97,项目名称:vice-players,代码行数:68,代码来源:CLocalPlayer.cpp

示例4: DoPulse

void CLightsyncManager::DoPulse ()
{
    // The point of this method is to get all players that should receive right now the lightweight
    // sync from all the other players. To make this efficient, we are using a queue in what the
    // players at the front have are more inminent to receive this sync. As all players have the same
    // far sync rate, just taking the players from the front, processing them  and pushing them to the
    // back will keep the order of priority to be processed.
    //
    // We also want to perform delta sync on stuff like the health, but it would require to know the last
    // value synced from every player to every player, because we are getting players from the front and
    // sending them all the other players data. This would be crazily inefficient and would require a lot
    // of mainteinance, so we will leave special entries in the queue to mark in what moment a player
    // health changed. This way, we will force the health sync for that player until the queue cycle
    // reaches that special entry again. As there might be multiple changes in a complete queue cycle, we
    // are also storing the delta context in what it happened, so we only consider the health unchanged
    // when we find the marker with the same context value.

    if ( g_pBandwidthSettings->bLightSyncEnabled == false )
        return;

    // For counting stats
    long iPacketsSent = 0;
    long iBitsSent = 0;

    // For limiting light sync processing
    long iLimitCounter = Max < uint > ( 10, g_pGame->GetPlayerManager ()->Count () / 25 );
    int iLightsyncRate = g_TickRateSettings.iLightSync;
    long long llTickCountNow = GetTickCount64_ ();
    while ( m_Queue.size() > 0 && m_Queue.front().ullTime + iLightsyncRate <= llTickCountNow && iLimitCounter > 0 )
    {
        SEntry entry = m_Queue.front ();
        m_Queue.pop_front ();

        CPlayer* pPlayer = entry.pPlayer;
        CPlayer::SLightweightSyncData& data = pPlayer->GetLightweightSyncData ();

        switch ( entry.eType )
        {
            case SYNC_PLAYER:
            {
                CLightsyncPacket packet;

                // Use this players far list
                const SViewerMapType& farList = pPlayer->GetFarPlayerList ();

                // For each far player
                for ( SViewerMapType ::const_iterator it = farList.begin (); it != farList.end (); ++it )
                {
                    CPlayer* pCurrent = it->first;
                    dassert ( pPlayer != pCurrent );

                    // Only send if he isn't network troubled.
                    if ( pCurrent->UhOhNetworkTrouble ( ) == false )
                    {
                        CPlayer::SLightweightSyncData& currentData = pCurrent->GetLightweightSyncData ();
                        packet.AddPlayer ( pCurrent );

                        // Calculate the delta sync
                        if ( fabs(currentData.health.fLastHealth - pCurrent->GetHealth()) > LIGHTSYNC_HEALTH_THRESHOLD ||
                             fabs(currentData.health.fLastArmor - pCurrent->GetArmor()) > LIGHTSYNC_HEALTH_THRESHOLD )
                        {
                            currentData.health.fLastHealth = pCurrent->GetHealth ();
                            currentData.health.fLastArmor = pCurrent->GetArmor ();
                            currentData.health.bSync = true;
                            currentData.health.uiContext++;

                            // Generate the health marker
                            SEntry marker;
                            marker.ullTime = 0;
                            marker.pPlayer = pCurrent;
                            marker.eType = DELTA_MARKER_HEALTH;
                            marker.uiContext = currentData.health.uiContext;
                            m_Queue.push_back ( marker );
                        }

                        CVehicle* pVehicle = pCurrent->GetOccupiedVehicle ();
                        if ( pVehicle && pCurrent->GetOccupiedVehicleSeat() == 0 )
                        {
                            if ( currentData.vehicleHealth.lastVehicle != pVehicle ||
                                 fabs(currentData.vehicleHealth.fLastHealth - pVehicle->GetHealth ()) > LIGHTSYNC_VEHICLE_HEALTH_THRESHOLD )
                            {
                                currentData.vehicleHealth.fLastHealth = pVehicle->GetHealth ();
                                currentData.vehicleHealth.lastVehicle = pVehicle;
                                currentData.vehicleHealth.bSync = true;
                                currentData.vehicleHealth.uiContext++;

                                // Generate the vehicle health marker
                                SEntry marker;
                                marker.ullTime = 0;
                                marker.pPlayer = pCurrent;
                                marker.eType = DELTA_MARKER_VEHICLE_HEALTH;
                                marker.uiContext = currentData.vehicleHealth.uiContext;
                                m_Queue.push_back ( marker );
                            }
                        }

                        if ( packet.Count () == LIGHTSYNC_MAX_PLAYERS )
                        {
                            iBitsSent += pPlayer->Send ( packet );
                            iPacketsSent++;
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:openvice,代码行数:101,代码来源:CLightsyncManager.cpp

示例5: Write

bool CVehiclePuresyncPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Got a player to send?
    if ( m_pSourceElement )
    {
        CPlayer * pSourcePlayer = static_cast < CPlayer * > ( m_pSourceElement );

        // Player is in a vehicle and is the driver?
        CVehicle* pVehicle = pSourcePlayer->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            // Player ID
            ElementID PlayerID = pSourcePlayer->GetID ();
            BitStream.Write ( PlayerID );

            // Write the time context of that player
            BitStream.Write ( pSourcePlayer->GetSyncTimeContext () );

            // Write his ping divided with 2 plus a small number so the client can find out when this packet was sent
            unsigned short usLatency = pSourcePlayer->GetPing ();
            BitStream.WriteCompressed ( usLatency );

            // Write the keysync data
            CControllerState ControllerState = pSourcePlayer->GetPad ()->GetCurrentControllerState ();
            WriteFullKeysync ( ControllerState, BitStream );

            // Write the vehicle matrix only if he's the driver
            CVector vecTemp;
            unsigned int uiSeat = pSourcePlayer->GetOccupiedVehicleSeat ();
            if ( uiSeat == 0 )
            {
                // Vehicle position
                SPositionSync position ( false );
                position.data.vecPosition = pVehicle->GetPosition ();
                BitStream.Write ( &position );

                // Vehicle rotation
                SRotationDegreesSync rotation;
                pVehicle->GetRotationDegrees ( rotation.data.vecRotation );
                BitStream.Write ( &rotation );

                // Move speed vector
                SVelocitySync velocity;
                velocity.data.vecVelocity = pVehicle->GetVelocity ();
                BitStream.Write ( &velocity );

                // Turn speed vector
                SVelocitySync turnSpeed;
                turnSpeed.data.vecVelocity = pVehicle->GetTurnSpeed ();
                BitStream.Write ( &turnSpeed );

                // Health
                SVehicleHealthSync health;
                health.data.fValue = pVehicle->GetHealth ();
                BitStream.Write ( &health );
            }

            // Player health and armor
            SPlayerHealthSync health;
            health.data.fValue = pSourcePlayer->GetHealth ();
            BitStream.Write ( &health );

            SPlayerArmorSync armor;
            armor.data.fValue = pSourcePlayer->GetArmor ();
            BitStream.Write ( &armor );

            // Weapon
            unsigned char ucWeaponType = pSourcePlayer->GetWeaponType ();

            // Flags
            SVehiclePuresyncFlags flags;
            flags.data.bIsWearingGoggles     = pSourcePlayer->IsWearingGoggles ();
            flags.data.bIsDoingGangDriveby   = pSourcePlayer->IsDoingGangDriveby ();
            flags.data.bIsSirenOrAlarmActive = pVehicle->IsSirenActive ();
            flags.data.bIsSmokeTrailEnabled  = pVehicle->IsSmokeTrailEnabled ();
            flags.data.bIsLandingGearDown    = pVehicle->IsLandingGearDown ();
            flags.data.bIsOnGround           = pVehicle->IsOnGround ();
            flags.data.bIsInWater            = pVehicle->IsInWater ();
            flags.data.bIsDerailed           = pVehicle->IsDerailed ();
            flags.data.bIsAircraft           = ( pVehicle->GetVehicleType () == VEHICLE_PLANE ||
                                                 pVehicle->GetVehicleType () == VEHICLE_HELI );
            flags.data.bHasAWeapon           = ( ucWeaponType != 0 );
            flags.data.bIsHeliSearchLightVisible = pVehicle->IsHeliSearchLightVisible ();
            BitStream.Write ( &flags );

            // Write the weapon stuff
            if ( flags.data.bHasAWeapon )
            {
                // Write the weapon slot
                SWeaponSlotSync slot;
                slot.data.uiSlot = pSourcePlayer->GetWeaponSlot ();
                BitStream.Write ( &slot );

                if ( flags.data.bIsDoingGangDriveby && CWeaponNames::DoesSlotHaveAmmo ( slot.data.uiSlot ) )
                {
                    // Write the ammo states
                    SWeaponAmmoSync ammo ( ucWeaponType, false, true );
                    ammo.data.usAmmoInClip = pSourcePlayer->GetWeaponAmmoInClip ();
                    BitStream.Write ( &ammo );

//.........这里部分代码省略.........
开发者ID:50p,项目名称:multitheftauto,代码行数:101,代码来源:CVehiclePuresyncPacket.cpp

示例6: Read

bool CVehiclePuresyncPacket::Read ( NetBitStreamInterface& BitStream )
{
    // Got a player to read?
    if ( m_pSourceElement )
    {
        CPlayer * pSourcePlayer = static_cast < CPlayer * > ( m_pSourceElement );

        // Player is in a vehicle?
        CVehicle* pVehicle = pSourcePlayer->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            // Read out the time context
            unsigned char ucTimeContext = 0;
            if ( !BitStream.Read ( ucTimeContext ) )
                return false;

            // Only read this packet if it matches the current time context that
            // player is in.
            if ( !pSourcePlayer->CanUpdateSync ( ucTimeContext ) )
            {
                return false;
            }

            // Read out the keysync data
            CControllerState ControllerState;
            if ( !ReadFullKeysync ( ControllerState, BitStream ) )
                return false;

            // Read out its position
            SPositionSync position ( false );
            if ( !BitStream.Read ( &position ) )
                return false;
            pSourcePlayer->SetPosition ( position.data.vecPosition );

            // Jax: don't allow any outdated packets through
            unsigned char ucSeat;
            if ( !BitStream.Read ( ucSeat ) )
                return false;
            if ( ucSeat != pSourcePlayer->GetOccupiedVehicleSeat () )
            {
                // Mis-matching seats can happen when we warp into a different one,
                // which will screw up the whole packet
                return false;
            }

            // Read out the vehicle matrix only if he's the driver
            unsigned int uiSeat = pSourcePlayer->GetOccupiedVehicleSeat ();
            if ( uiSeat == 0 )
            {
                // Read out the vehicle rotation in degrees
                SRotationDegreesSync rotation;
                if( !BitStream.Read ( &rotation ) )
                    return false;

                // Set it
                pVehicle->SetPosition ( position.data.vecPosition );
                pVehicle->SetRotationDegrees ( rotation.data.vecRotation );

                // Move speed vector
                SVelocitySync velocity;
                if ( !BitStream.Read ( &velocity ) )
                    return false;

                pVehicle->SetVelocity ( velocity.data.vecVelocity );
                pSourcePlayer->SetVelocity ( velocity.data.vecVelocity );

                // Turn speed vector
                SVelocitySync turnSpeed;
                if ( !BitStream.Read ( &turnSpeed ) )
                    return false;

                pVehicle->SetTurnSpeed ( turnSpeed.data.vecVelocity );

                // Health
                SVehicleHealthSync health;
                if ( !BitStream.Read ( &health ) )
                    return false;
                float fPreviousHealth = pVehicle->GetHealth ();                
                float fHealth = health.data.fValue;

                // Less than last time?
                if ( fHealth < fPreviousHealth )
                {                 
                    // Grab the delta health
                    float fDeltaHealth = fPreviousHealth - fHealth;

					if ( fDeltaHealth > 0.0f )
					{
						// Call the onVehicleDamage event
						CLuaArguments Arguments;
						Arguments.PushNumber ( fDeltaHealth );
						pVehicle->CallEvent ( "onVehicleDamage", Arguments );
					}
                }
                pVehicle->SetHealth ( fHealth );

                // Trailer chain
                CVehicle* pTowedByVehicle = pVehicle;
                CVehicle* pTrailer = NULL;
                ElementID TrailerID;
//.........这里部分代码省略.........
开发者ID:50p,项目名称:multitheftauto,代码行数:101,代码来源:CVehiclePuresyncPacket.cpp

示例7: Write


//.........这里部分代码省略.........
                    BitStream.WriteCompressed ( pObject->GetModel () );

                    // Alpha
                    SEntityAlphaSync alpha;
                    alpha.data.ucAlpha = pObject->GetAlpha ();
                    BitStream.Write ( &alpha );

                    // Double sided
                    bool bIsDoubleSided = pObject->IsDoubleSided ();
                    BitStream.WriteBit ( bIsDoubleSided );

                    // Moving
                    const CPositionRotationAnimation* pMoveAnimation = pObject->GetMoveAnimation ();
                    if ( pMoveAnimation )
                    {
                         BitStream.WriteBit ( true );
                         pMoveAnimation->ToBitStream ( BitStream, true );
                    }
                    else
                    {
                        BitStream.WriteBit ( false );
                    }

                    // Scale
                    float fScale = pObject->GetScale ();
                    BitStream.Write ( fScale );

                    // Static
                    bool bStatic = pObject->IsStatic ();
                    BitStream.WriteBit ( bStatic );

                    // Health
                    SObjectHealthSync health;
                    health.data.fValue = pObject->GetHealth ();
                    BitStream.Write ( &health );

                    break;
                }

                case CElement::PICKUP:
                {
                    CPickup* pPickup = static_cast < CPickup* > ( pElement );

                    // Position
                    position.data.vecPosition = pPickup->GetPosition ();
                    BitStream.Write ( &position );

                    // Grab the model and write it
                    unsigned short usModel = pPickup->GetModel ();
                    BitStream.WriteCompressed ( usModel );

                    // Write if it's visible
                    bool bVisible = pPickup->IsVisible ();
                    BitStream.WriteBit ( bVisible );

                    // Write the type
                    SPickupTypeSync pickupType;
                    pickupType.data.ucType = pPickup->GetPickupType ();
                    BitStream.Write ( &pickupType );

                    switch ( pPickup->GetPickupType () )
                    {
                        case CPickup::ARMOR:
                        {
                            SPlayerArmorSync armor;
                            armor.data.fValue = pPickup->GetAmount ();
开发者ID:qaisjp,项目名称:green-candy,代码行数:67,代码来源:CEntityAddPacket.cpp

示例8: Process

void CVehiclePool::Process()
{
	BYTE x=0;
	CVehicle *pVehicle;
	DWORD dwThisTime = GetTickCount();

	while(x != MAX_VEHICLES)
	{
		if(GetSlotState(x) == TRUE) { // It's inuse.
			pVehicle = m_pVehicles[x];

			if(m_bIsActive[x]) {
	
				if(pVehicle->GetHealth() == 0.0f) { // It's dead
					SetForRespawn(x);
				}
				else if(pVehicle->HasExceededWorldBoundries(
					pNetGame->m_WorldBounds[0],pNetGame->m_WorldBounds[1],
					pNetGame->m_WorldBounds[2],pNetGame->m_WorldBounds[3]))
				{
					if(pVehicle->IsOkToRespawn()) {
						SetForRespawn(x);
					}
				}
				else if(pVehicle->GetVehicleSubtype() != VEHICLE_SUBTYPE_BOAT &&
						pVehicle->GetVehicleSubtype() != VEHICLE_SUBTYPE_PLANE &&
						pVehicle->HasSunk()) // Not boat and has sunk.
				{
					SetForRespawn(x);
				}
				else 
				{
					if(pVehicle->IsDriverLocalPlayer()) {
						pVehicle->SetInvulnerable(FALSE);
					} else {
						pVehicle->SetInvulnerable(TRUE);
					}

					// Lock vehicles beyond given radius.
					if(pVehicle->GetDistanceFromLocalPlayerPed() > 300.0f) {
						pVehicle->SetLockedState(1);
					} else {
						pVehicle->SetLockedState(0);
					}

					if(pVehicle->GetVehicleSubtype() == VEHICLE_SUBTYPE_BIKE) {
						pVehicle->VerifyControlState();
					}

					// code to respawn vehicle after it has been idle for 4 minutes
					pVehicle->UpdateLastDrivenTime();

					if(pVehicle->m_bHasBeenDriven) {
						if((dwThisTime - pVehicle->m_dwTimeSinceLastDriven) > 250000) {
							SetForRespawn(x);
						}
					}						
				}
			}
			else // !m_bIsActive
			{
				if(m_iRespawnDelay[x] != 0) {
					m_iRespawnDelay[x]--;
				}
				else {
					if(pVehicle->IsOkToRespawn()) {
						Spawn(x,m_SpawnInfo[x].byteVehicleType,&m_SpawnInfo[x].vecPos,
							m_SpawnInfo[x].fRotation,m_SpawnInfo[x].iColor1,m_SpawnInfo[x].iColor2);
					}
				}	
			}		
		}

		x++;

	}
}
开发者ID:LBRGeorge,项目名称:jmnvc,代码行数:77,代码来源:vehiclepool.cpp

示例9: Process

void CVehiclePool::Process()
{
	// Process all vehicles in the vehicle pool.
	CVehicle *pVehicle;
	DWORD dwThisTime = GetTickCount();
	
	CPlayerPool* pPlayerPool = pNetGame->GetPlayerPool();
	CLocalPlayer* pLocalPlayer = pPlayerPool->GetLocalPlayer();

	int iLocalPlayersInRange = 0;
	if (pLocalPlayer)
		iLocalPlayersInRange = pLocalPlayer->DetermineNumberOfPlayersInLocalRange();

	ProcessWaitingList();

	for(VEHICLEID x = 0; x != MAX_VEHICLES; x++)
	{
		if(GetSlotState(x) == TRUE)
		{
			// It's in use.
			pVehicle = m_pVehicles[x];

			if(m_bIsActive[x])
			{
				if(pVehicle->IsDriverLocalPlayer()) {
					pVehicle->SetInvulnerable(FALSE);
				} else {
					pVehicle->SetInvulnerable(TRUE);
				}

				if (pVehicle->GetHealth() == 0.0f) // || pVehicle->IsWrecked()) // It's dead
				{
					if (pLocalPlayer->m_LastVehicle == x) // Notify server of death
					{
						NotifyVehicleDeath(x);
					}
					continue;
				}
	
				if( pVehicle->GetVehicleSubtype() != VEHICLE_SUBTYPE_BOAT &&
					pVehicle->HasSunk() ) // Not boat and has sunk.
				{
					if (pLocalPlayer->m_LastVehicle == x) {
						NotifyVehicleDeath(x);
					}
					continue;
				}
									
				// Active and in world.
				pLocalPlayer->ProcessUndrivenSync(x, pVehicle, iLocalPlayersInRange); // sync unoccupied vehicle if needed

				/* This has an impact on undriven passenger sync. check for driver instead 
				// Kye: This the source of the audio bug?
				if(!pVehicle->IsOccupied()) {
					pVehicle->SetEngineState(FALSE);
				} else {
					pVehicle->SetEngineState(TRUE);
				}*/

				// Update the actual ingame pointer if it's not the same as the one we have listed.
				if(pVehicle->m_pVehicle != m_pGTAVehicles[x]) {
					m_pGTAVehicles[x] = pVehicle->m_pVehicle;
				}

				pVehicle->ProcessMarkers();
			}
		}
	}
}
开发者ID:jovazxc,项目名称:samp,代码行数:69,代码来源:vehiclepool.cpp


注:本文中的CVehicle::GetHealth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。