From 2cf27ad8378ad8f7bb5763c641b480378915f462 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Tue, 20 Dec 2022 02:56:04 +0100 Subject: [PATCH] potentially fix ghost car bug --- src/Client.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Client.cpp b/src/Client.cpp index 197bf68..6532d55 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -1,6 +1,7 @@ #include "Client.h" #include "CustomAssert.h" +#include "LuaAPI.h" #include "TServer.h" #include #include @@ -12,6 +13,8 @@ void TClient::DeleteCar(int Ident) { return Ident == elem.ID(); }); if (iter != mVehicleData.end()) { + std::string Destroy = "Od:" + std::to_string(GetID()) + "-" + std::to_string(iter->ID()); + LuaAPI::MP::Engine->Network().SendToAll(nullptr, StringToVector(Destroy), true, true); mVehicleData.erase(iter); } else { beammp_debug("tried to erase a vehicle that doesn't exist (not an error)"); @@ -20,6 +23,10 @@ void TClient::DeleteCar(int Ident) { void TClient::ClearCars() { std::unique_lock lock(mVehicleDataMutex); + for (const auto& Car : mVehicleData) { + std::string Destroy = "Od:" + std::to_string(GetID()) + "-" + std::to_string(Car.ID()); + LuaAPI::MP::Engine->Network().SendToAll(nullptr, StringToVector(Destroy), true, true); + } mVehicleData.clear(); }