mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-04-27 17:16:31 +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() {}
|
RacingControlComponent::~RacingControlComponent() {}
|
||||||
|
|
||||||
void RacingControlComponent::OnPlayerLoaded(Entity* player) {
|
void RacingControlComponent::OnPlayerLoaded(Entity* player) {
|
||||||
// If the race has already started, send the player back to the main world.
|
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||||
if (m_Loaded) {
|
if (!inventoryComponent) {
|
||||||
auto* playerInstance = dynamic_cast<Player*>(player);
|
|
||||||
|
|
||||||
playerInstance->SendToZone(m_MainWorld);
|
|
||||||
|
|
||||||
return;
|
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++;
|
m_LoadedPlayers++;
|
||||||
|
|
||||||
Game::logger->Log("RacingControlComponent", "Loading player %i",
|
Game::logger->Log("RacingControlComponent", "Loading player %i",
|
||||||
m_LoadedPlayers);
|
m_LoadedPlayers);
|
||||||
|
m_LobbyPlayers.push_back(player->GetObjectID());
|
||||||
m_LobbyPlayers.push_back(objectID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||||
@ -100,8 +104,13 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
|||||||
|
|
||||||
if (item == nullptr) {
|
if (item == nullptr) {
|
||||||
Game::logger->Log("RacingControlComponent", "Failed to find item");
|
Game::logger->Log("RacingControlComponent", "Failed to find item");
|
||||||
|
auto* playerInstance = dynamic_cast<Player*>(player);
|
||||||
|
if(playerInstance){
|
||||||
|
m_LoadedPlayers--;
|
||||||
|
playerInstance->SendToZone(m_MainWorld);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the vehicle's starting position.
|
// Calculate the vehicle's starting position.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user