feat(VehiclePreview): Stop preview on spawn

This commit is contained in:
Yimura 2022-03-31 01:34:36 +02:00
parent dac6cf8cc6
commit a4f00f70b3
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682
3 changed files with 8 additions and 1 deletions

View File

@ -46,7 +46,7 @@ namespace big
g_fiber_pool->queue_job([this]
{
while (g_running && g->spawn.preview_vehicle && g_gui.m_opened)
while (g_running && m_running && g->spawn.preview_vehicle && g_gui.m_opened)
{
auto location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER::PLAYER_PED_ID(), 2.5f, 2.5f, .5f);
if (m_current_veh == -1)
@ -99,6 +99,11 @@ namespace big
g_thread_pool->push([this] { preview_loop(); });
}
void vehicle_preview_service::stop_preview()
{
m_running = false;
}
void vehicle_preview_service::load()
{
std::ifstream file(m_vehicle_file.get_path());

View File

@ -26,6 +26,7 @@ namespace big
void preview_loop();
void set_preview_vehicle(const nlohmann::json& item);
void stop_preview();
private:
void load();

View File

@ -75,6 +75,7 @@ namespace big
vehicle::max_vehicle(veh);
}
g_vehicle_preview_service->stop_preview();
});
if (g->spawn.preview_vehicle && ImGui::IsItemHovered())