Exemplo n.º 1
0
void RespawnVehicle( RakNet::BitStream * pBitStream, RakNet::Packet * pPacket )
{
	// Read the vehicle id
	EntityId vehicleId;
	pBitStream->ReadCompressed( vehicleId );

	// Read the spawn position
	CVector3 vecPosition;
	pBitStream->Read( vecPosition );

	// Read teh spawn rotation
	CVector3 vecRotation;
	pBitStream->Read( vecRotation );

	// Get a pointer to the network vehicle
	CNetworkVehicle * pNetworkVehicle = pCore->GetVehicleManager()->Get( vehicleId );

	// Is the vehicle pointer valid?
	if( pNetworkVehicle )
	{
		// Set the spawn position
		pNetworkVehicle->SetSpawnPosition( CVector3( vecPosition.fX, vecPosition.fY, (vecPosition.fZ - 1.0f) ) );

		// Set the spawn rotation
		pNetworkVehicle->SetSpawnRotation( vecRotation );

		// Handle the respawn with the vehicle
		pNetworkVehicle->HandleRespawn();
	}
}