diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index 7a4d98ea..12f4201a 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -61,23 +61,27 @@ RacingControlComponent::RacingControlComponent(Entity* parent) RacingControlComponent::~RacingControlComponent() {} void RacingControlComponent::OnPlayerLoaded(Entity* player) { - // If the race has already started, send the player back to the main world. - if (m_Loaded) { - auto* playerInstance = dynamic_cast(player); - - playerInstance->SendToZone(m_MainWorld); - + auto* inventoryComponent = player->GetComponent(); + if (!inventoryComponent) { return; } - const auto objectID = player->GetObjectID(); + auto* vehicle = inventoryComponent->FindItemByLot(8092); + + // If the race has already started, send the player back to the main world. + if (m_Loaded || !vehicle) { + auto* playerInstance = dynamic_cast(player); + if(playerInstance){ + playerInstance->SendToZone(m_MainWorld); + } + return; + } m_LoadedPlayers++; Game::logger->Log("RacingControlComponent", "Loading player %i", m_LoadedPlayers); - - m_LobbyPlayers.push_back(objectID); + m_LobbyPlayers.push_back(player->GetObjectID()); } void RacingControlComponent::LoadPlayerVehicle(Entity* player, @@ -100,8 +104,13 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, if (item == nullptr) { Game::logger->Log("RacingControlComponent", "Failed to find item"); - + auto* playerInstance = dynamic_cast(player); + if(playerInstance){ + m_LoadedPlayers--; + playerInstance->SendToZone(m_MainWorld); + } return; + } // Calculate the vehicle's starting position.