mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 06:57:28 +00:00
fix: Players are able to join a race without having a race car (#1149)
* Fixed Scrapped Racecar Stuck Issue Changed RacingControlComponent to boot players back to the hub world when trying to race after dismantling a vehicle. * Modified OnPlayerLoaded to fix Vehicle Inventory issue * Change 3 --------- Co-authored-by: David Markowitz <EmosewaMC@gmail.com>
This commit is contained in:
parent
74cc4176e1
commit
288991ef49
@ -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*>(player);
|
||||
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
|
||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||
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*>(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*>(player);
|
||||
if(playerInstance){
|
||||
m_LoadedPlayers--;
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Calculate the vehicle's starting position.
|
||||
|
Loading…
Reference in New Issue
Block a user