Advertisement
Guest User

PersistCar

a guest
Apr 21st, 2019
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.52 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "common.hpp"
  4. #include "natives.hpp"
  5. #include "VehicleHelper.h"
  6. #include "ModelAttachment.h"
  7.  
  8. namespace big
  9. {
  10.     class persistcar
  11.     {
  12.     public:
  13.         static void save_vehicle(Vehicle vehicle, std::string file_name)
  14.         {
  15.             if (ENTITY::DOES_ENTITY_EXIST(vehicle) == FALSE || ENTITY::IS_ENTITY_A_VEHICLE(vehicle) == FALSE)
  16.             {
  17.                 LOG_ERROR("Persist Car was passed an incorrect entity");
  18.                 return;
  19.             }
  20.  
  21.             auto file_path = check_vehicle_folder();
  22.             file_path /= file_name;
  23.             std::ofstream file(file_path, std::ios::out | std::ios::trunc);
  24.             file << get_full_vehicle_json(vehicle).dump(4);
  25.             file.close();
  26.         }
  27.  
  28.         static Vehicle load_vehicle(std::string file_name)
  29.         {
  30.             auto file_path = check_vehicle_folder();
  31.             file_path /= file_name;
  32.             std::ifstream file(file_path);
  33.  
  34.             nlohmann::json vehicle_json;
  35.             file >> vehicle_json;
  36.             file.close();
  37.  
  38.             return spawn_vehicle_full(vehicle_json, PLAYER::PLAYER_PED_ID());
  39.         }
  40.  
  41.         static std::vector<std::string> list_files()
  42.         {
  43.             auto file_path = check_vehicle_folder();
  44.             std::vector<std::string> return_value;
  45.             for (const auto& p : std::filesystem::directory_iterator(file_path))
  46.                 if (p.path().extension() == ".json")
  47.                     return_value.push_back(p.path().filename().generic_string());
  48.             return return_value;
  49.         }
  50.  
  51.         static Vehicle clone_ped_car(Ped ped)
  52.         {
  53.             if (PED::IS_PED_IN_ANY_VEHICLE(ped, FALSE))
  54.                 return spawn_vehicle_full(get_full_vehicle_json(PED::GET_VEHICLE_PED_IS_IN(ped, FALSE)), ped);
  55.             return NULL;
  56.         }
  57.  
  58.     private:
  59.         static Vehicle spawn_vehicle_full(nlohmann::json vehicle_json, Ped ped)
  60.         {
  61.             Vehicle vehicle = spawn_vehicle(vehicle_json, ped);
  62.             if (!vehicle_json["Tow"].is_null())
  63.             {
  64.                 Vehicle tow = spawn_vehicle(vehicle_json["Tow"], ped);
  65.                 auto pos = ENTITY::GET_ENTITY_COORDS(tow, true);
  66.                 pos.x -= 10;
  67.                 ENTITY::SET_ENTITY_COORDS_NO_OFFSET(tow, pos.x, pos.y, 0.f, TRUE, TRUE, FALSE);
  68.                 VEHICLE::ATTACH_VEHICLE_TO_TOW_TRUCK(vehicle, tow, -1, 0.f, 0.5f, 0.f);
  69.                 VEHICLE::_SET_TOW_TRUCK_CRANE_HEIGHT(vehicle, 1.f);
  70.                 Vector3 rotation = ENTITY::GET_ENTITY_ROTATION(tow, 2);
  71.                 ENTITY::SET_ENTITY_ROTATION(tow, 0, 0, rotation.z, 2, TRUE);
  72.             }
  73.             else if(!vehicle_json["Trailer"].is_null())
  74.             {
  75.                 Vehicle trailer = spawn_vehicle(vehicle_json["Trailer"], ped);
  76.                 VEHICLE::ATTACH_VEHICLE_TO_TRAILER(vehicle, trailer, 1.0f);
  77.                 Vector3 rotation = ENTITY::GET_ENTITY_ROTATION(trailer, 2);
  78.                 ENTITY::SET_ENTITY_ROTATION(trailer, 0, 0, rotation.z, 2, TRUE);
  79.             }
  80.             Vector3 rotation = ENTITY::GET_ENTITY_ROTATION(vehicle, 2);
  81.             ENTITY::SET_ENTITY_ROTATION(vehicle, rotation.x, 0, rotation.z, 2, TRUE);
  82.             return vehicle;
  83.         }
  84.  
  85.         static Vehicle spawn_vehicle(nlohmann::json vehicle_json, Ped ped)
  86.         {
  87.             Vehicle vehicle = spawn_vehicle_json(vehicle_json, ped);
  88.             std::vector<nlohmann::json> model_attachments = vehicle_json["Model Attachments"];
  89.             for (nlohmann::json model_attachment : model_attachments)
  90.             {
  91.                 auto attachment = model_attachment.get<model_attachment::model_attachment>();
  92.                 STREAMING::REQUEST_MODEL(attachment.model_hash);
  93.                 Object object = OBJECT::CREATE_OBJECT(attachment.model_hash, 0, 0, 0, TRUE, FALSE, FALSE);
  94.                 ENTITY::ATTACH_ENTITY_TO_ENTITY(object, vehicle, 0, attachment.position.x, attachment.position.y, attachment.position.z, attachment.rotation.x, attachment.rotation.y, attachment.rotation.z, false, false, false, false, 0, true);
  95.                 STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(attachment.model_hash);
  96.             }
  97.             std::vector<nlohmann::json> vehicle_attachments = vehicle_json["Vehicle Attachments"];
  98.             for (nlohmann::json vehicle_attachment : vehicle_attachments)
  99.             {
  100.                 Vehicle vehicle_to_attach = spawn_vehicle_json(vehicle_attachment["Vehicle"], ped);
  101.                 auto attachment = vehicle_attachment["Model Attachment"].get<model_attachment::model_attachment>();
  102.                 ENTITY::ATTACH_ENTITY_TO_ENTITY(vehicle_to_attach, vehicle, 0, attachment.position.x, attachment.position.y, attachment.position.z, attachment.rotation.x, attachment.rotation.y, attachment.rotation.z, false, false, false, false, 0, true);
  103.                 VEHICLE::SET_VEHICLE_IS_CONSIDERED_BY_PLAYER(vehicle_to_attach, false);
  104.             }
  105.             return vehicle;
  106.         }
  107.  
  108.         static Vehicle spawn_vehicle_json(nlohmann::json vehicle_json, Ped ped)
  109.         {
  110.             Hash vehicle_hash = vehicle_json["Vehicle Model Hash"];
  111.  
  112.             auto pos = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
  113.             Vehicle vehicle = CreateVehicle(vehicle_hash, pos.x, pos.y, pos.z, ENTITY::GET_ENTITY_HEADING(ped));
  114.             VEHICLE::SET_VEHICLE_DIRT_LEVEL(vehicle, 0.0f);
  115.             VEHICLE::SET_VEHICLE_MOD_KIT(vehicle, 0);
  116.             VEHICLE::SET_VEHICLE_TYRES_CAN_BURST(vehicle, FALSE);
  117.             VEHICLE::SET_VEHICLE_COLOURS(vehicle, vehicle_json["Primary Color"], vehicle_json["Secondary Color"]);
  118.             if (!vehicle_json["Custom Primary Color"].is_null())
  119.             {
  120.                 std::vector<int> primary_custom_color = vehicle_json["Custom Primary Color"];
  121.                 VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehicle, primary_custom_color[0], primary_custom_color[1], primary_custom_color[2]);
  122.             }
  123.             if (!vehicle_json["Custom Secondary Color"].is_null())
  124.             {
  125.                 std::vector<int> secondary_custom_color = vehicle_json["Custom Secondary Color"];
  126.                 VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(vehicle, secondary_custom_color[0], secondary_custom_color[1], secondary_custom_color[2]);
  127.             }
  128.             VEHICLE::SET_VEHICLE_WINDOW_TINT(vehicle, vehicle_json["Vehicle Window Tint"]);
  129.             if (!vehicle_json["Radio Station"].is_null())
  130.                 AUDIO::SET_VEH_RADIO_STATION(vehicle, vehicle_json["Radio Station"].get<std::string>().c_str());
  131.             VEHICLE::SET_VEHICLE_NUMBER_PLATE_TEXT(vehicle, vehicle_json["Plate Text"].get<std::string>().c_str());
  132.             VEHICLE::SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehicle, vehicle_json["Plate Text Index"]);
  133.             VEHICLE::SET_VEHICLE_EXTRA_COLOURS(vehicle, vehicle_json["Pearlescent Color"], vehicle_json["Wheel Color"]);
  134.             std::map<int, bool> vehicle_extras = vehicle_json["Vehicle Extras"];
  135.             for (int i = 0; i <= 20; i++)
  136.             {
  137.                 if (VEHICLE::DOES_EXTRA_EXIST(vehicle, i))
  138.                     VEHICLE::SET_VEHICLE_EXTRA(vehicle, i, vehicle_extras[i]);
  139.             }
  140.             if (!vehicle_json["Vehicle Livery"].is_null())
  141.             {
  142.                 VEHICLE::SET_VEHICLE_LIVERY(vehicle, vehicle_json["Vehicle Livery"]);
  143.             }
  144.             if (VEHICLE::IS_THIS_MODEL_A_CAR(ENTITY::GET_ENTITY_MODEL(vehicle)) == TRUE || VEHICLE::IS_THIS_MODEL_A_BIKE(ENTITY::GET_ENTITY_MODEL(vehicle)))
  145.             {
  146.                 VEHICLE::SET_VEHICLE_WHEEL_TYPE(vehicle, vehicle_json["Wheel Type"]);
  147.                 for (int i = MOD_SPOILERS; i <= MOD_LIVERY; i++)
  148.                 {
  149.                     BOOL bModOn = !vehicle_json[mod_names[i]].is_null();
  150.                     if (bModOn == TRUE)
  151.                     {
  152.                         if (i == MOD_TIRESMOKE)
  153.                         {
  154.                             std::vector<int> tire_smoke_color = vehicle_json["Tire Smoke Color"];
  155.                             VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, tire_smoke_color[0], tire_smoke_color[1], tire_smoke_color[2]);
  156.                             VEHICLE::TOGGLE_VEHICLE_MOD(vehicle, MOD_TIRESMOKE, TRUE);
  157.                         }
  158.                         else if (vehicle_json[mod_names[i]].is_array())
  159.                         {
  160.                             std::vector<int> mod = vehicle_json[mod_names[i]];
  161.                             VEHICLE::SET_VEHICLE_MOD(vehicle, i, mod[0], mod[1]);
  162.                         }
  163.                         else
  164.                         {
  165.                             VEHICLE::TOGGLE_VEHICLE_MOD(vehicle, i, TRUE);
  166.                         }
  167.                     }
  168.                 }
  169.                 std::vector<bool> neon_lights = vehicle_json["Neon Lights"];
  170.                 for (int i = NEON_LEFT; i <= NEON_BACK; i++)
  171.                     VEHICLE::_SET_VEHICLE_NEON_LIGHT_ENABLED(vehicle, i, neon_lights[i]);
  172.                 std::vector<int> neon_color = vehicle_json["Neon Color"];
  173.                 VEHICLE::_SET_VEHICLE_NEON_LIGHTS_COLOUR(vehicle, neon_color[0], neon_color[1], neon_color[2]);
  174.                 if (VEHICLE::IS_VEHICLE_A_CONVERTIBLE(vehicle, 0))
  175.                 {
  176.                     int convertableState = vehicle_json["Convertable State"];
  177.                     if (convertableState == 0 || convertableState == 3 || convertableState == 5)
  178.                         VEHICLE::RAISE_CONVERTIBLE_ROOF(vehicle, TRUE);
  179.                     else
  180.                         VEHICLE::LOWER_CONVERTIBLE_ROOF(vehicle, TRUE);
  181.                 }
  182.                 VEHICLE::SET_VEHICLE_INTERIOR_COLOUR(vehicle, vehicle_json["Interior Color"]);
  183.                 VEHICLE::SET_VEHICLE_DASHBOARD_COLOUR(vehicle, vehicle_json["Dash Color"]);
  184.                 if (vehicle_json["Clan Logo"] == TRUE)
  185.                     AddClanLogoToVehicle(vehicle, ped);
  186.                 VEHICLE::SET_VEHICLE_HEADLIGHT_COLOUR(vehicle, vehicle_json["Headlight Color"]);
  187.             }
  188.             return vehicle;
  189.         }
  190.  
  191.         static nlohmann::json get_full_vehicle_json(Vehicle vehicle)
  192.         {
  193.             nlohmann::json vehicle_json = get_vehicle_json(vehicle);
  194.             vehicle_json["Model Attachments"] = get_model_attachments(vehicle);
  195.             vehicle_json["Vehicle Attachments"] = get_vehicle_attachents(vehicle);
  196.             Vehicle tow = VEHICLE::GET_ENTITY_ATTACHED_TO_TOW_TRUCK(vehicle);
  197.             if (ENTITY::DOES_ENTITY_EXIST(tow))
  198.             {
  199.                 vehicle_json["Tow"] = get_vehicle_json(tow);
  200.                 vehicle_json["Tow"]["Model Attachments"] = get_model_attachments(tow, true);
  201.                 vehicle_json["Tow"]["Vehicle Attachments"] = get_vehicle_attachents(tow);
  202.             }
  203.             if (VEHICLE::IS_VEHICLE_ATTACHED_TO_TRAILER(vehicle))
  204.             {
  205.                 Vehicle trailer;
  206.                 VEHICLE::GET_VEHICLE_TRAILER_VEHICLE(vehicle, &trailer);
  207.                 vehicle_json["Trailer"] = get_vehicle_json(trailer);
  208.                 vehicle_json["Trailer"]["Model Attachments"] = get_model_attachments(trailer);
  209.                 vehicle_json["Trailer"]["Vehicle Attachments"] = get_vehicle_attachents(trailer);
  210.             }
  211.             return vehicle_json;
  212.         }
  213.  
  214.         static model_attachment::model_attachment get_model_attachment(Vehicle vehicle, Object object)
  215.         {
  216.             Vector3 object_location = ENTITY::GET_ENTITY_COORDS(object, 0);
  217.             Vector3 location = ENTITY::GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS(vehicle, object_location.x, object_location.y, object_location.z);
  218.             Vector3 object_rotation = ENTITY::GET_ENTITY_ROTATION(object, 0);
  219.             Vector3 vehicle_rotation = ENTITY::GET_ENTITY_ROTATION(vehicle, 0);
  220.             Vector3 rotation;
  221.             rotation.x = (object_rotation.x - vehicle_rotation.x);
  222.             rotation.y = (object_rotation.y - vehicle_rotation.y);
  223.             rotation.z = (object_rotation.z - vehicle_rotation.z);
  224.             model_attachment::model_attachment attachment = { ENTITY::GET_ENTITY_MODEL(object), location, rotation };
  225.             return attachment;
  226.         }
  227.  
  228.         static nlohmann::json get_model_attachments(Vehicle vehicle, bool is_towed_vehicle = false)
  229.         {
  230.             std::vector<nlohmann::json> attached_objects;
  231.             rage::CObjectInterface* objIF = g_pointers->m_replay_interface->pCObjectInterface;
  232.             int numObj = objIF->iMaxObjects;
  233.             for (int i = 0; i < numObj; i++)
  234.             {
  235.                 rage::CObject* pCObject = objIF->get_object(i);
  236.                 if (pCObject == nullptr)
  237.                     continue;
  238.  
  239.                 Object object = g_pointers->m_ptr_to_handle(pCObject);
  240.                 if (object == 0)
  241.                     break;
  242.  
  243.                 if (!ENTITY::IS_ENTITY_ATTACHED_TO_ENTITY(vehicle, object))
  244.                     continue;
  245.  
  246.                 if (is_towed_vehicle && ENTITY::GET_ENTITY_MODEL(object) == 0xBC344305) //Don't save tow hook.
  247.                     continue;
  248.  
  249.                 attached_objects.push_back(get_model_attachment(vehicle, object));
  250.             };
  251.             return attached_objects;
  252.         }
  253.  
  254.         static nlohmann::json get_vehicle_attachents(Vehicle vehicle)
  255.         {
  256.             Vehicle trailer;
  257.             VEHICLE::GET_VEHICLE_TRAILER_VEHICLE(vehicle, &trailer);
  258.             std::vector<nlohmann::json> attached_vehicles;
  259.             rage::CVehicleInterface* vehicle_interface = g_pointers->m_replay_interface->pCVehicleInterface;
  260.             for (int i = 0; i < vehicle_interface->iMaxVehicles; i++)
  261.             {
  262.                 auto* vehicle_ptr = vehicle_interface->get_vehicle(i);
  263.                 if (vehicle_ptr == nullptr)
  264.                     continue;
  265.  
  266.                 Vehicle object = g_pointers->m_ptr_to_handle((rage::CObject*)vehicle_ptr);
  267.                 if (object == 0)
  268.                     break;
  269.  
  270.                 if (!ENTITY::IS_ENTITY_ATTACHED_TO_ENTITY(vehicle, object))
  271.                     continue;
  272.  
  273.                 if (object == VEHICLE::GET_ENTITY_ATTACHED_TO_TOW_TRUCK(vehicle) || VEHICLE::IS_VEHICLE_ATTACHED_TO_TOW_TRUCK(object, vehicle))
  274.                     continue;
  275.  
  276.                 if (object == trailer || VEHICLE::IS_VEHICLE_ATTACHED_TO_TRAILER(object))
  277.                     continue;
  278.  
  279.                 nlohmann::json model_attachment;
  280.                 model_attachment["Vehicle"] = get_vehicle_json(object);
  281.                 model_attachment["Model Attachment"] = get_model_attachment(vehicle, object);
  282.                 attached_vehicles.push_back(model_attachment);
  283.             }
  284.             return attached_vehicles;
  285.         }
  286.  
  287.         static nlohmann::json get_vehicle_json(Vehicle vehicle)
  288.         {
  289.             nlohmann::json vehicle_json;
  290.  
  291.             vehicle_json["Vehicle Model Hash"] = ENTITY::GET_ENTITY_MODEL(vehicle);
  292.             int primary_color, secondary_color;
  293.             VEHICLE::GET_VEHICLE_COLOURS(vehicle, &primary_color, &secondary_color);
  294.             vehicle_json["Primary Color"] = primary_color;
  295.             vehicle_json["Secondary Color"] = secondary_color;
  296.             if (VEHICLE::GET_IS_VEHICLE_PRIMARY_COLOUR_CUSTOM(vehicle))
  297.             {
  298.                 int custom_primary_color[3]{};
  299.                 VEHICLE::GET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehicle, &custom_primary_color[0], &custom_primary_color[1], &custom_primary_color[2]);
  300.                 vehicle_json["Custom Primary Color"] = custom_primary_color;
  301.             }
  302.             if (VEHICLE::GET_IS_VEHICLE_SECONDARY_COLOUR_CUSTOM(vehicle))
  303.             {
  304.                 int custom_secondary_color[3]{};
  305.                 VEHICLE::GET_VEHICLE_CUSTOM_SECONDARY_COLOUR(vehicle, &custom_secondary_color[0], &custom_secondary_color[1], &custom_secondary_color[2]);
  306.                 vehicle_json["Custom Secondary Color"] = custom_secondary_color;
  307.             }
  308.             vehicle_json["Vehicle Window Tint"] = VEHICLE::GET_VEHICLE_WINDOW_TINT(vehicle);
  309.             auto radio_station = AUDIO::GET_PLAYER_RADIO_STATION_NAME();
  310.             if (radio_station == nullptr)
  311.                 radio_station = "OFF";
  312.             vehicle_json["Radio Station"] = radio_station;
  313.             vehicle_json["Plate Text"] = VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT(vehicle);
  314.             vehicle_json["Plate Text Index"] = VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehicle);
  315.             int pearlescent_color, wheel_color;
  316.             VEHICLE::GET_VEHICLE_EXTRA_COLOURS(vehicle, &pearlescent_color, &wheel_color);
  317.             vehicle_json["Pearlescent Color"] = pearlescent_color;
  318.             vehicle_json["Wheel Color"] = wheel_color;
  319.             std::map<int,bool> vehicle_extras;
  320.             for (int i = 0; i <= 20; i++)
  321.             {
  322.                 if (VEHICLE::DOES_EXTRA_EXIST(vehicle, i))
  323.                     vehicle_extras[i] = !VEHICLE::IS_VEHICLE_EXTRA_TURNED_ON(vehicle, i);
  324.             }
  325.             vehicle_json["Vehicle Extras"] = vehicle_extras;
  326.             if ((VEHICLE::GET_VEHICLE_LIVERY_COUNT(vehicle) > 1) && VEHICLE::GET_VEHICLE_LIVERY(vehicle) >= 0)
  327.             {
  328.                 vehicle_json["Vehicle Livery"] = VEHICLE::GET_VEHICLE_LIVERY(vehicle);
  329.             }
  330.             if (VEHICLE::IS_THIS_MODEL_A_CAR(ENTITY::GET_ENTITY_MODEL(vehicle)) == TRUE || VEHICLE::IS_THIS_MODEL_A_BIKE(ENTITY::GET_ENTITY_MODEL(vehicle)))
  331.             {
  332.                 vehicle_json["Wheel Type"] = VEHICLE::GET_VEHICLE_WHEEL_TYPE(vehicle);
  333.                 for (int i = MOD_SPOILERS; i <= MOD_LIVERY; i++)
  334.                 {
  335.                     BOOL is_mod_on = VEHICLE::IS_TOGGLE_MOD_ON(vehicle, i);
  336.                     if (i == MOD_TIRESMOKE && is_mod_on == TRUE)
  337.                     {
  338.                         int tire_smoke_color[3]{};
  339.                         VEHICLE::GET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, &tire_smoke_color[0], &tire_smoke_color[1], &tire_smoke_color[2]);
  340.                         vehicle_json["Tire Smoke Color"] = tire_smoke_color;
  341.                     }
  342.                     else if (is_mod_on == TRUE)
  343.                     {
  344.                         vehicle_json[mod_names[i]] = "TOGGLE";
  345.                     }
  346.                     if (VEHICLE::GET_VEHICLE_MOD(vehicle, i) != -1)
  347.                     {
  348.                         int vehicle_mod[2] = { VEHICLE::GET_VEHICLE_MOD(vehicle, i), VEHICLE::GET_VEHICLE_MOD_VARIATION(vehicle, i) };
  349.                         vehicle_json[mod_names[i]] = vehicle_mod;
  350.                     }
  351.                 }
  352.                 bool neon_lights[4]{};
  353.                 for (int i = NEON_LEFT; i <= NEON_BACK; i++)
  354.                     neon_lights[i] = VEHICLE::_IS_VEHICLE_NEON_LIGHT_ENABLED(vehicle, i);
  355.                 int neon_color[3]{};
  356.                 VEHICLE::_GET_VEHICLE_NEON_LIGHTS_COLOUR(vehicle, &neon_color[0], &neon_color[1], &neon_color[2]);
  357.                 vehicle_json["Neon Color"] = neon_color;
  358.                 vehicle_json["Neon Lights"] = neon_lights;
  359.                 if (VEHICLE::IS_VEHICLE_A_CONVERTIBLE(vehicle, 0))
  360.                     vehicle_json["Convertable State"] = VEHICLE::GET_CONVERTIBLE_ROOF_STATE(vehicle);
  361.                 int interior_color, dashboard_color;
  362.                 VEHICLE::GET_VEHICLE_INTERIOR_COLOUR(vehicle, &interior_color);
  363.                 VEHICLE::GET_VEHICLE_DASHBOARD_COLOUR(vehicle, &dashboard_color);
  364.                 vehicle_json["Interior Color"] = interior_color;
  365.                 vehicle_json["Dash Color"] = dashboard_color;
  366.                 vehicle_json["Clan Logo"] = GRAPHICS::_DOES_VEHICLE_HAVE_DECAL(vehicle, 0);
  367.                 vehicle_json["Headlight Color"] = VEHICLE::GET_VEHICLE_HEADLIGHT_COLOUR(vehicle);
  368.             }
  369.             return vehicle_json;
  370.         }
  371.  
  372.         static std::filesystem::path check_vehicle_folder()
  373.         {
  374.             auto file_path = std::filesystem::path(std::getenv("appdata"));
  375.             file_path /= "BigBaseV2";
  376.             file_path /= "Vehicles";
  377.  
  378.             if (!std::filesystem::exists(file_path))
  379.             {
  380.                 std::filesystem::create_directory(file_path);
  381.             }
  382.             else if (!std::filesystem::is_directory(file_path))
  383.             {
  384.                 std::filesystem::remove(file_path);
  385.                 std::filesystem::create_directory(file_path);
  386.             }
  387.  
  388.             return file_path;
  389.         }
  390.     };
  391. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement