Fix an issue where spawn max could crash the game for some vehicles (#341)

This commit is contained in:
aa15032261 2022-07-17 04:36:05 +08:00 committed by GitHub
parent 399d41d74a
commit 14e0a112ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 369 additions and 244 deletions

View File

@ -163,6 +163,18 @@ static const std::map<int, std::string> lsc_headlight_colors = {
{ XENON_BACKLIGHT, "Backlight" } { XENON_BACKLIGHT, "Backlight" }
}; };
static const std::map<int, std::string> lsc_missing_horns = {
{ HORN_XMAS_BACKGROUND, "Festival Loop 1 Bg" },
{ HORN_XMAS2_BACKGROUND, "Festival Loop 2 Bg" },
{ HORN_XMAS3_BACKGROUND, "Festival Loop 3 Bg" },
{ HORN_LOW_LONG, "Low (Long)" },
{ HORN_LOW_SHORT, "Low (Short)" },
{ HORN_MID_LONG, "Mid (Long)" },
{ HORN_MID_SHORT, "Mid (Short)" },
{ HORN_HIGH_LONG, "High (Long)" },
{ HORN_HIGH_SHORT, "High (Short)" }
};
static const std::map<std::string, std::vector<int>> lsc_tire_smoke_rgb = { static const std::map<std::string, std::vector<int>> lsc_tire_smoke_rgb = {
{ "White", { TIRESMOKE_COLOR_WHITE } }, { "White", { TIRESMOKE_COLOR_WHITE } },
{ "Black", { TIRESMOKE_COLOR_BLACK } }, { "Black", { TIRESMOKE_COLOR_BLACK } },

View File

@ -386,9 +386,44 @@ enum VehicleModType
enum CustomVehicleModType enum CustomVehicleModType
{ {
MOD_WHEEL_TYPE = -101, MOD_MODEL_HASH = -100,
MOD_PLATE_STYLE = -102,
MOD_WINDOW_TINT = -103 MOD_WHEEL_TYPE = -101,
MOD_PLATE_STYLE = -102,
MOD_WINDOW_TINT = -103,
MOD_FRONTWHEEL_VAR = -104,
MOD_REARWHEEL_VAR = -105,
MOD_NEON_FRONT_ON = -106,
MOD_NEON_BACK_ON = -107,
MOD_NEON_LEFT_ON = -108,
MOD_NEON_RIGHT_ON = -109,
MOD_TIRE_CAN_BURST = -110,
MOD_PRIMARY_COL = -111,
MOD_SECONDARY_COL = -112,
MOD_PEARLESCENT_COL = -113,
MOD_WHEEL_COL = -114,
MOD_INTERIOR_COL = -115,
MOD_DASHBOARD_COL = -116,
MOD_XENON_COL = -117,
MOD_PRIMARY_COL_R = -118,
MOD_PRIMARY_COL_G = -119,
MOD_PRIMARY_COL_B = -120,
MOD_SECONDARY_COL_R = -121,
MOD_SECONDARY_COL_G = -122,
MOD_SECONDARY_COL_B = -123,
MOD_TIRESMOKE_COL_R = -124,
MOD_TIRESMOKE_COL_G = -125,
MOD_TIRESMOKE_COL_B = -126,
MOD_NEON_COL_R = -127,
MOD_NEON_COL_G = -128,
MOD_NEON_COL_B = -129,
}; };
@ -448,7 +483,13 @@ enum VehicleModHorns
HORN_XMAS2, HORN_XMAS2,
HORN_XMAS2_BACKGROUND, HORN_XMAS2_BACKGROUND,
HORN_XMAS3, HORN_XMAS3,
HORN_XMAS3_BACKGROUND HORN_XMAS3_BACKGROUND,
HORN_LOW_LONG,
HORN_LOW_SHORT,
HORN_MID_LONG,
HORN_MID_SHORT,
HORN_HIGH_LONG,
HORN_HIGH_SHORT
}; };
enum VehicleAddonLevel enum VehicleAddonLevel

View File

@ -22,37 +22,8 @@ namespace big
} }
} }
void vehicle_helper::set_mp_parameters_for_vehicle(Vehicle vehicle) const char* vehicle_helper::get_mod_slot_name(Hash model, Vehicle vehicle, int mod_slot)
{ {
DECORATOR::DECOR_SET_INT(vehicle, "MPBitset", 0);
auto networkId = NETWORK::VEH_TO_NET(vehicle);
if (NETWORK::NETWORK_GET_ENTITY_IS_NETWORKED(vehicle))
NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(networkId, true);
VEHICLE::SET_VEHICLE_IS_STOLEN(vehicle, FALSE);
}
Vehicle vehicle_helper::create_vehicle(Hash modelHash, float x, float y, float z, float heading)
{
while (!STREAMING::HAS_MODEL_LOADED(modelHash))
{
STREAMING::REQUEST_MODEL(modelHash);
script::get_current()->yield();
}
*(unsigned short*)big::g_pointers->m_model_spawn_bypass = 0x9090;
Vehicle vehicle = VEHICLE::CREATE_VEHICLE(modelHash, x, y, z, heading, TRUE, FALSE, FALSE);
*(unsigned short*)big::g_pointers->m_model_spawn_bypass = 0x0574;
script::get_current()->yield(); //This allows the car to initalize so when we write things like radio station, it will overwrite.
ENTITY::SET_ENTITY_CLEANUP_BY_ENGINE_(vehicle, TRUE);
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), vehicle, -1);
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(modelHash);
if (*big::g_pointers->m_is_session_started)
set_mp_parameters_for_vehicle(vehicle);
return vehicle;
}
const char* vehicle_helper::get_mod_slot_name(int mod_slot, Vehicle vehicle)
{
Hash model = ENTITY::GET_ENTITY_MODEL(vehicle);
switch (mod_slot) switch (mod_slot)
{ {
case MOD_HOOD: case MOD_HOOD:
@ -181,7 +152,7 @@ namespace big
{46, "HORN_XM15_1"}, {47, "HORN_XM15_2"}, {48, "HORN_XM15_3"} {46, "HORN_XM15_1"}, {47, "HORN_XM15_2"}, {48, "HORN_XM15_3"}
}; };
const char* vehicle_helper::get_mod_name(int mod, int mod_slot, int mod_count, Vehicle vehicle) const char* vehicle_helper::get_mod_name(Hash model, Vehicle vehicle, int mod_slot, int mod, int mod_count)
{ {
if (mod_count == 0) if (mod_count == 0)
return ""; return "";
@ -195,7 +166,7 @@ namespace big
} }
return ""; return "";
} }
Hash model = ENTITY::GET_ENTITY_MODEL(vehicle);
if (mod_slot == MOD_FRONTWHEEL || mod_slot == MOD_REARWHEEL) if (mod_slot == MOD_FRONTWHEEL || mod_slot == MOD_REARWHEEL)
{ {
if (mod == -1) if (mod == -1)
@ -227,6 +198,8 @@ namespace big
case MOD_TRANSMISSION: case MOD_TRANSMISSION:
return HUD::GET_LABEL_TEXT_(fmt::format("CMOD_GBX_{}", (mod + 1)).c_str()); return HUD::GET_LABEL_TEXT_(fmt::format("CMOD_GBX_{}", (mod + 1)).c_str());
} }
if (mod > -1) if (mod > -1)
{ {
if (mod_slot == MOD_SIDESKIRT && VEHICLE::GET_NUM_VEHICLE_MODS(vehicle, MOD_SIDESKIRT) < 2) if (mod_slot == MOD_SIDESKIRT && VEHICLE::GET_NUM_VEHICLE_MODS(vehicle, MOD_SIDESKIRT) < 2)
@ -258,4 +231,42 @@ namespace big
return HUD::GET_LABEL_TEXT_("CMOD_DEF_0"); return HUD::GET_LABEL_TEXT_("CMOD_DEF_0");
} }
} }
static const std::map<Hash, std::map<int, std::vector<int32_t>>> mod_blacklists = {
{ VEHICLE_BANSHEE, {
{ MOD_SPOILERS, { 3, 4 } },
{ MOD_COLUMNSHIFTERLEVERS, { 0, 1, 2 } },
{ MOD_SPEAKERS, { 0 } },
{ MOD_LIVERY, { 15, 16 } }
} },
{ VEHICLE_SENTINEL, {
{ MOD_SPOILERS, { 4, 5 } },
{ MOD_COLUMNSHIFTERLEVERS, { 0, 1, 2 } },
{ MOD_SPEAKERS, { 0 } },
{ MOD_LIVERY, { 0, 1 } }
} }
};
bool vehicle_helper::check_mod_blacklist(Hash model, int mod_slot, int mod)
{
if (mod_blacklists.find(model) == mod_blacklists.end())
{
return false;
}
auto veh_slot_blacklist = mod_blacklists.find(model)->second;
if (veh_slot_blacklist.find(mod_slot) == veh_slot_blacklist.end())
{
return false;
}
auto veh_mod_blacklist = veh_slot_blacklist.find(mod_slot)->second;
if (std::find(veh_mod_blacklist.begin(), veh_mod_blacklist.end(), mod) != veh_mod_blacklist.end())
{
return true;
}
return false;
}
} }

View File

@ -7,10 +7,9 @@ namespace big
class vehicle_helper class vehicle_helper
{ {
public: public:
static const char* get_mod_slot_name(int mod_slot, Vehicle vehicle); static bool check_mod_blacklist(Hash model, int mod_slot, int mod);
static const char* get_mod_name(int mod, int mod_slot, int mod_count, Vehicle vehicle); static const char* get_mod_slot_name(Hash model, Vehicle vehicle, int mod_slot);
static const char* get_mod_name(Hash model, Vehicle vehicle, int mod_slot, int mod, int mod_count);
static void add_clan_logo_to_vehicle(Vehicle vehicle, Ped ped); static void add_clan_logo_to_vehicle(Vehicle vehicle, Ped ped);
static void set_mp_parameters_for_vehicle(Vehicle vehicle);
static Vehicle create_vehicle(Hash modelHash, float x, float y, float z, float heading);
}; };
} }

View File

@ -8,6 +8,7 @@
#include "teleport.hpp" #include "teleport.hpp"
#include "script_global.hpp" #include "script_global.hpp"
#include "gta\VehicleValues.h" #include "gta\VehicleValues.h"
#include "services/vehicle_helper/vehicle_helper.hpp"
namespace big::vehicle namespace big::vehicle
{ {
@ -48,6 +49,15 @@ namespace big::vehicle
return speed; return speed;
} }
inline void set_mp_bitset(Vehicle veh)
{
DECORATOR::DECOR_SET_INT(veh, "MPBitset", 0);
auto networkId = NETWORK::VEH_TO_NET(veh);
if (NETWORK::NETWORK_GET_ENTITY_IS_NETWORKED(veh))
NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(networkId, true);
VEHICLE::SET_VEHICLE_IS_STOLEN(veh, FALSE);
}
inline void bring(Vehicle veh, Vector3 location, bool put_in = true, int seatIdx = -1) inline void bring(Vehicle veh, Vector3 location, bool put_in = true, int seatIdx = -1)
{ {
if (!ENTITY::IS_ENTITY_A_VEHICLE(veh)) return g_notification_service->push_error("Vehicle", "Invalid handle"); if (!ENTITY::IS_ENTITY_A_VEHICLE(veh)) return g_notification_service->push_error("Vehicle", "Invalid handle");
@ -164,14 +174,12 @@ namespace big::vehicle
for (uint8_t i = 0; !STREAMING::HAS_MODEL_LOADED(hash) && i < 100; i++) for (uint8_t i = 0; !STREAMING::HAS_MODEL_LOADED(hash) && i < 100; i++)
{ {
STREAMING::REQUEST_MODEL(hash); STREAMING::REQUEST_MODEL(hash);
script::get_current()->yield(); script::get_current()->yield();
} }
if (!STREAMING::HAS_MODEL_LOADED(hash)) if (!STREAMING::HAS_MODEL_LOADED(hash))
{ {
g_notification_service->push_warning("Spawn", "Failed to spawn model, did you give an incorrect model?"); g_notification_service->push_warning("Spawn", "Failed to spawn model, did you give an incorrect model?");
return -1; return -1;
} }
@ -185,18 +193,13 @@ namespace big::vehicle
if (*g_pointers->m_is_session_started) if (*g_pointers->m_is_session_started)
{ {
DECORATOR::DECOR_SET_INT(veh, "MPBitset", 0); set_mp_bitset(veh);
ENTITY::SET_ENTITY_CLEANUP_BY_ENGINE_(veh, true);
int networkId = NETWORK::VEH_TO_NET(veh);
if (NETWORK::NETWORK_GET_ENTITY_IS_NETWORKED(veh))
NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(networkId, true);
VEHICLE::SET_VEHICLE_IS_STOLEN(veh, false);
} }
return veh; return veh;
} }
inline Vehicle clone(std::map<int, int32_t>& data, Vector3 location, float heading) inline Vehicle clone_from_vehicle_data(std::map<int, int32_t>& data, Vector3 location, float heading)
{ {
Vector3 tmpLocation = { location.x, location.y, 1200.0f }; Vector3 tmpLocation = { location.x, location.y, 1200.0f };
if (location.z > 1000.0f && location.z < 1400.0) if (location.z > 1000.0f && location.z < 1400.0)
@ -279,13 +282,81 @@ namespace big::vehicle
return veh_data; return veh_data;
} }
inline void telport_into_veh(Vehicle veh) inline std::map<int, int32_t> get_owned_mods_from_vehicle(Vehicle vehicle)
{
std::map<int, int32_t> owned_mods;
owned_mods[MOD_MODEL_HASH] = ENTITY::GET_ENTITY_MODEL(vehicle);
for (int i = MOD_NEON_COL_B; i <= MOD_MODEL_HASH; i++)
{
owned_mods[i] = 0;
}
for (int slot = MOD_SPOILERS; slot <= MOD_LIVERY; slot++)
{
int count = VEHICLE::GET_NUM_VEHICLE_MODS(vehicle, slot);
if (count > 0)
{
owned_mods[slot] = VEHICLE::GET_VEHICLE_MOD(vehicle, slot);
}
}
owned_mods[MOD_PLATE_STYLE] = VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehicle);
owned_mods[MOD_WINDOW_TINT] = VEHICLE::GET_VEHICLE_WINDOW_TINT(vehicle);
owned_mods[MOD_WHEEL_TYPE] = VEHICLE::GET_VEHICLE_WHEEL_TYPE(vehicle);
VEHICLE::GET_VEHICLE_COLOURS(vehicle, &owned_mods[MOD_PRIMARY_COL], &owned_mods[MOD_SECONDARY_COL]);
VEHICLE::GET_VEHICLE_EXTRA_COLOURS(vehicle, &owned_mods[MOD_PEARLESCENT_COL], &owned_mods[MOD_WHEEL_COL]);
VEHICLE::GET_VEHICLE_INTERIOR_COLOR_(vehicle, &owned_mods[MOD_INTERIOR_COL]);
VEHICLE::GET_VEHICLE_DASHBOARD_COLOR_(vehicle, &owned_mods[MOD_DASHBOARD_COL]);
owned_mods[MOD_XENON_COL] = VEHICLE::GET_VEHICLE_XENON_LIGHTS_COLOR_(vehicle);
VEHICLE::GET_VEHICLE_CUSTOM_PRIMARY_COLOUR(
vehicle, &owned_mods[MOD_PRIMARY_COL_R],
&owned_mods[MOD_PRIMARY_COL_G], &owned_mods[MOD_PRIMARY_COL_B]
);
VEHICLE::GET_VEHICLE_CUSTOM_PRIMARY_COLOUR(
vehicle, &owned_mods[MOD_SECONDARY_COL_R],
&owned_mods[MOD_SECONDARY_COL_G], &owned_mods[MOD_SECONDARY_COL_B]
);
VEHICLE::GET_VEHICLE_TYRE_SMOKE_COLOR(
vehicle, &owned_mods[MOD_TIRESMOKE_COL_R],
&owned_mods[MOD_TIRESMOKE_COL_G], &owned_mods[MOD_TIRESMOKE_COL_B]
);
VEHICLE::GET_VEHICLE_NEON_LIGHTS_COLOUR_(
vehicle, &owned_mods[MOD_NEON_COL_R],
&owned_mods[MOD_NEON_COL_B], &owned_mods[MOD_NEON_COL_B]
);
owned_mods[MOD_TIRE_CAN_BURST] = !VEHICLE::GET_VEHICLE_TYRES_CAN_BURST(vehicle);
owned_mods[MOD_TYRE_SMOKE] = VEHICLE::IS_TOGGLE_MOD_ON(vehicle, MOD_TYRE_SMOKE);
owned_mods[MOD_TURBO] = VEHICLE::IS_TOGGLE_MOD_ON(vehicle, MOD_TURBO);
owned_mods[MOD_XENON_LIGHTS] = VEHICLE::IS_TOGGLE_MOD_ON(vehicle, MOD_XENON_LIGHTS);
owned_mods[MOD_NEON_LEFT_ON] = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, NEON_LEFT);
owned_mods[MOD_NEON_RIGHT_ON] = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, NEON_RIGHT);
owned_mods[MOD_NEON_FRONT_ON] = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, NEON_FRONT);
owned_mods[MOD_NEON_BACK_ON] = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, NEON_BACK);
owned_mods[MOD_FRONTWHEEL_VAR] = VEHICLE::GET_VEHICLE_MOD_VARIATION(vehicle, MOD_FRONTWHEEL);
owned_mods[MOD_REARWHEEL_VAR] = VEHICLE::GET_VEHICLE_MOD_VARIATION(vehicle, MOD_REARWHEEL);
return owned_mods;
}
inline void teleport_into_vehicle(Vehicle veh)
{ {
PED::SET_PED_INTO_VEHICLE(self::ped, veh, -1); PED::SET_PED_INTO_VEHICLE(self::ped, veh, -1);
} }
inline void max_vehicle(Vehicle veh) inline void max_vehicle(Vehicle veh)
{ {
Hash model = ENTITY::GET_ENTITY_MODEL(veh);
VEHICLE::SET_VEHICLE_MOD_KIT(veh, 0); VEHICLE::SET_VEHICLE_MOD_KIT(veh, 0);
VEHICLE::TOGGLE_VEHICLE_MOD(veh, 18 /* Turbo */, TRUE); VEHICLE::TOGGLE_VEHICLE_MOD(veh, 18 /* Turbo */, TRUE);
VEHICLE::TOGGLE_VEHICLE_MOD(veh, 20 /* Tire Smoke */, TRUE); VEHICLE::TOGGLE_VEHICLE_MOD(veh, 20 /* Tire Smoke */, TRUE);
@ -293,16 +364,39 @@ namespace big::vehicle
VEHICLE::SET_VEHICLE_WINDOW_TINT(veh, 1); VEHICLE::SET_VEHICLE_WINDOW_TINT(veh, 1);
VEHICLE::SET_VEHICLE_TYRES_CAN_BURST(veh, false); VEHICLE::SET_VEHICLE_TYRES_CAN_BURST(veh, false);
for (int i = 0; i < 50; i++) for (int slot = MOD_SPOILERS; slot <= MOD_LIVERY; slot++)
{ {
if ( if (slot == MOD_LIVERY) {
i != MOD_LIVERY continue;
) { }
VEHICLE::SET_VEHICLE_MOD(veh, i, VEHICLE::GET_NUM_VEHICLE_MODS(veh, i) - 1, true);
int count = VEHICLE::GET_NUM_VEHICLE_MODS(veh, slot);
if (count > 0)
{
int selected_mod = -1;
for (int mod = count - 1; mod >= -1; mod--)
{
if (vehicle_helper::check_mod_blacklist(model, slot, mod))
{
continue;
}
selected_mod = mod;
break;
}
if (selected_mod != -1)
{
VEHICLE::SET_VEHICLE_MOD(veh, slot, selected_mod, true);
}
} }
} }
} }
static constexpr char const* rgb_types[] = { "Off", "Fade", "Spasm" }; static constexpr char const* rgb_types[] = { "Off", "Fade", "Spasm" };
static constexpr int driving_styles[] = { 443, 524861 }; static constexpr int driving_styles[] = { 443, 524861 };

View File

@ -14,43 +14,16 @@ namespace big
static Vehicle player_vehicle = 0; static Vehicle player_vehicle = 0;
static bool ready = true; static bool ready = true;
static std::map<int, int> owned_mods; static std::map<int, int32_t> owned_mods;
static std::map<int, std::string> slot_display_names; static std::map<int, std::string> slot_display_names;
static std::map<int, std::map<int, std::string>> mod_display_names; static std::map<int, std::map<int, std::string>> mod_display_names;
static std::map<std::string, std::vector<int>> front_wheel_map; static std::map<std::string, std::vector<int>> front_wheel_map;
static std::map<std::string, std::vector<int>> rear_wheel_map; static std::map<std::string, std::vector<int>> rear_wheel_map;
static int primary_color_rgb[3] = { 255, 255, 255 };
static int secondary_color_rgb[3] = { 255, 255, 255 };
static int tire_smoke_color_rgb[3] = { 255, 255, 255 };
static int neon_light_color_rgb[3] = { 255, 255, 255 };
static int selected_slot = -1; static int selected_slot = -1;
static bool is_bennys = false; static bool is_bennys = false;
static int front_wheel_stock_mod = -1; static int front_wheel_stock_mod = -1;
static bool front_wheel_custom = false;
static int rear_wheel_stock_mod = -1; static int rear_wheel_stock_mod = -1;
static bool rear_wheel_custom = false;
static bool can_tires_burst = false;
static bool tiresmoke = false;
static bool turbo = false;
static bool xenon = false;
static bool neon_left = false;
static bool neon_right = false;
static bool neon_front = false;
static bool neon_back = false;
static int primary_color = 0;
static int secondary_color = 0;
static int pearlescent = 0;
static int wheel_color = 0;
static int interior_color = 0;
static int dashboard_color = 0;
static int headlight_color = 0;
static Hash veh_model_hash = 0;
if (self::veh == 0 || player_vehicle != self::veh) if (self::veh == 0 || player_vehicle != self::veh)
{ {
@ -84,31 +57,11 @@ namespace big
VEHICLE::SET_VEHICLE_MOD_KIT(player_vehicle, 0); VEHICLE::SET_VEHICLE_MOD_KIT(player_vehicle, 0);
VEHICLE::GET_VEHICLE_COLOURS(player_vehicle, &primary_color, &secondary_color); Hash model = ENTITY::GET_ENTITY_MODEL(player_vehicle);
VEHICLE::GET_VEHICLE_EXTRA_COLOURS(player_vehicle, &pearlescent, &wheel_color);
VEHICLE::GET_VEHICLE_INTERIOR_COLOR_(player_vehicle, &interior_color);
VEHICLE::GET_VEHICLE_DASHBOARD_COLOR_(player_vehicle, &dashboard_color);
headlight_color = VEHICLE::GET_VEHICLE_XENON_LIGHTS_COLOR_(player_vehicle);
VEHICLE::GET_VEHICLE_CUSTOM_PRIMARY_COLOUR(player_vehicle, &primary_color_rgb[0], &primary_color_rgb[1], &primary_color_rgb[2]); owned_mods = vehicle::get_owned_mods_from_vehicle(player_vehicle);
VEHICLE::GET_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle, &secondary_color_rgb[0], &secondary_color_rgb[1], &secondary_color_rgb[2]); VEHICLE::SET_VEHICLE_MOD_KIT(player_vehicle, 0);
VEHICLE::GET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, &tire_smoke_color_rgb[0], &tire_smoke_color_rgb[1], &tire_smoke_color_rgb[2]);
VEHICLE::GET_VEHICLE_NEON_LIGHTS_COLOUR_(player_vehicle, &neon_light_color_rgb[0], &neon_light_color_rgb[1], &neon_light_color_rgb[2]);
can_tires_burst = !VEHICLE::GET_VEHICLE_TYRES_CAN_BURST(player_vehicle);
tiresmoke = VEHICLE::IS_TOGGLE_MOD_ON(player_vehicle, MOD_TYRE_SMOKE);
turbo = VEHICLE::IS_TOGGLE_MOD_ON(player_vehicle, MOD_TURBO);
xenon = VEHICLE::IS_TOGGLE_MOD_ON(player_vehicle, MOD_XENON_LIGHTS);
neon_left = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT);
neon_right = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT);
neon_front = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT);
neon_back = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK);
front_wheel_custom = VEHICLE::GET_VEHICLE_MOD_VARIATION(player_vehicle, MOD_FRONTWHEEL);
rear_wheel_custom = VEHICLE::GET_VEHICLE_MOD_VARIATION(player_vehicle, MOD_REARWHEEL);
std::map<int, int> tmp_owned_mods;
std::map<int, std::string> tmp_slot_display_names; std::map<int, std::string> tmp_slot_display_names;
std::map<int, std::map<int, std::string>> tmp_mod_display_names; std::map<int, std::map<int, std::string>> tmp_mod_display_names;
std::map<std::string, std::vector<int>> tmp_front_wheel_map; std::map<std::string, std::vector<int>> tmp_front_wheel_map;
@ -118,30 +71,24 @@ namespace big
tmp_slot_display_names[MOD_WINDOW_TINT] = "Window Tint"; tmp_slot_display_names[MOD_WINDOW_TINT] = "Window Tint";
tmp_slot_display_names[MOD_WHEEL_TYPE] = "Wheel Type"; tmp_slot_display_names[MOD_WHEEL_TYPE] = "Wheel Type";
tmp_owned_mods[MOD_PLATE_STYLE] = VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(player_vehicle);
tmp_mod_display_names[MOD_PLATE_STYLE].insert(lsc_plate_styles.begin(), lsc_plate_styles.end()); tmp_mod_display_names[MOD_PLATE_STYLE].insert(lsc_plate_styles.begin(), lsc_plate_styles.end());
tmp_owned_mods[MOD_WINDOW_TINT] = VEHICLE::GET_VEHICLE_WINDOW_TINT(player_vehicle);
tmp_mod_display_names[MOD_WINDOW_TINT].insert(lsc_window_tint_types.begin(), lsc_window_tint_types.end()); tmp_mod_display_names[MOD_WINDOW_TINT].insert(lsc_window_tint_types.begin(), lsc_window_tint_types.end());
tmp_owned_mods[MOD_WHEEL_TYPE] = VEHICLE::GET_VEHICLE_WHEEL_TYPE(player_vehicle);
tmp_mod_display_names[MOD_WHEEL_TYPE].insert(lsc_wheel_styles.begin(), lsc_wheel_styles.end()); tmp_mod_display_names[MOD_WHEEL_TYPE].insert(lsc_wheel_styles.begin(), lsc_wheel_styles.end());
is_bennys = tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_BENNYS_ORIGINAL || is_bennys = owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_BENNYS_ORIGINAL ||
tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_BENNYS_BESPOKE || owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_BENNYS_BESPOKE ||
tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_OPEN_WHEEL || owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_OPEN_WHEEL ||
tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_STREET || owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_STREET ||
tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_TRACK; owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_TRACK;
for (int slot = MOD_SPOILERS; slot <= MOD_LIVERY; slot++) for (int slot = MOD_SPOILERS; slot <= MOD_LIVERY; slot++)
{ {
int count = VEHICLE::GET_NUM_VEHICLE_MODS(player_vehicle, slot); int count = VEHICLE::GET_NUM_VEHICLE_MODS(player_vehicle, slot);
if (count > 0) if (count > 0)
{ {
int owner_mod = VEHICLE::GET_VEHICLE_MOD(player_vehicle, slot); int owner_mod = owned_mods[slot];
tmp_owned_mods[slot] = owner_mod;
std::string slot_name = vehicle_helper::get_mod_slot_name(slot, player_vehicle); std::string slot_name = vehicle_helper::get_mod_slot_name(model, player_vehicle, slot);
if (slot_name.empty()) if (slot_name.empty())
{ {
continue; continue;
@ -149,11 +96,18 @@ namespace big
tmp_slot_display_names[slot] = slot_name; tmp_slot_display_names[slot] = slot_name;
std::map<int, std::string> mod_names; std::map<int, std::string> mod_names;
for (int mod = -1; mod < count; mod++) for (int mod = -1; mod < count; mod++)
{ {
if (vehicle_helper::check_mod_blacklist(model, slot, mod))
{
continue;
}
bool is_repeated = false; bool is_repeated = false;
std::string mod_name = vehicle_helper::get_mod_name(mod, slot, count, player_vehicle); std::string mod_name = vehicle_helper::get_mod_name(model, player_vehicle, slot, mod, count);
if (mod_name.empty() || mod_name == "NULL") if (mod_name.empty() || mod_name == "NULL")
{ {
continue; continue;
@ -185,18 +139,24 @@ namespace big
if (tmp_front_wheel_map[mod_name].size() > 1) if (tmp_front_wheel_map[mod_name].size() > 1)
{ {
is_repeated = true; is_repeated = true;
if (!is_bennys)
{
if (mod == owner_mod)
{
front_wheel_custom = true;
}
}
} }
} }
else if(slot == MOD_REARWHEEL) else if(slot == MOD_REARWHEEL)
{ {
if (is_bennys)
{
if (mod_name.rfind("Chrome ", 0) == 0)
{
std::string new_mod_name = mod_name.substr(7);
if (tmp_rear_wheel_map[new_mod_name].size() > 0)
{
mod_name = new_mod_name;
}
}
}
tmp_rear_wheel_map[mod_name].push_back(mod); tmp_rear_wheel_map[mod_name].push_back(mod);
if (mod == owner_mod) if (mod == owner_mod)
@ -207,11 +167,6 @@ namespace big
if (tmp_rear_wheel_map[mod_name].size() > 1) if (tmp_rear_wheel_map[mod_name].size() > 1)
{ {
is_repeated = true; is_repeated = true;
if (mod == owner_mod)
{
rear_wheel_custom = true;
}
} }
} }
@ -220,11 +175,16 @@ namespace big
mod_names[mod] = mod_name; mod_names[mod] = mod_name;
} }
} }
tmp_mod_display_names[slot] = mod_names; tmp_mod_display_names[slot] = mod_names;
} }
} }
owned_mods = tmp_owned_mods; if (tmp_mod_display_names.count(MOD_HORNS) > 0)
{
tmp_mod_display_names[MOD_HORNS].insert(lsc_missing_horns.begin(), lsc_missing_horns.end());
}
slot_display_names = tmp_slot_display_names; slot_display_names = tmp_slot_display_names;
mod_display_names = tmp_mod_display_names; mod_display_names = tmp_mod_display_names;
front_wheel_map = tmp_front_wheel_map; front_wheel_map = tmp_front_wheel_map;
@ -265,24 +225,24 @@ namespace big
ImGui::Separator(); ImGui::Separator();
components::small_text("Mod Options"); components::small_text("Mod Options");
if (ImGui::Checkbox("Bulletproof Tires", &can_tires_burst)) if (ImGui::Checkbox("Bulletproof Tires", (bool*)&owned_mods[MOD_TIRE_CAN_BURST]))
{ {
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_TYRES_CAN_BURST(player_vehicle, !can_tires_burst); VEHICLE::SET_VEHICLE_TYRES_CAN_BURST(player_vehicle, !owned_mods[MOD_TIRE_CAN_BURST]);
}); });
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Checkbox("Turbo", &turbo)) if (ImGui::Checkbox("Turbo", (bool*)&owned_mods[MOD_TURBO]))
{ {
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_TURBO, turbo); VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_TURBO, owned_mods[MOD_TURBO]);
}); });
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Checkbox("Tiresmoke", &tiresmoke)) if (ImGui::Checkbox("Tiresmoke", (bool*)&owned_mods[MOD_TYRE_SMOKE]))
{ {
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_TYRE_SMOKE, tiresmoke); VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_TYRE_SMOKE, owned_mods[MOD_TYRE_SMOKE]);
}); });
} }
@ -307,9 +267,9 @@ namespace big
if (selected_slot != -1) if (selected_slot != -1)
{ {
static auto wheel_stock_mod = &front_wheel_stock_mod; auto wheel_stock_mod = &front_wheel_stock_mod;
static auto wheel_custom = &front_wheel_custom; auto wheel_custom = &owned_mods[MOD_FRONTWHEEL_VAR];
static bool is_wheel_mod = false; bool is_wheel_mod = false;
if (selected_slot == MOD_FRONTWHEEL) if (selected_slot == MOD_FRONTWHEEL)
{ {
@ -318,7 +278,7 @@ namespace big
else if (selected_slot == MOD_REARWHEEL) else if (selected_slot == MOD_REARWHEEL)
{ {
wheel_stock_mod = &rear_wheel_stock_mod; wheel_stock_mod = &rear_wheel_stock_mod;
wheel_custom = &rear_wheel_custom; wheel_custom = &owned_mods[MOD_REARWHEEL_VAR];
is_wheel_mod = true; is_wheel_mod = true;
} }
else else
@ -346,7 +306,7 @@ namespace big
if (ImGui::Selectable(name.c_str(), item_selected)) if (ImGui::Selectable(name.c_str(), item_selected))
{ {
g_fiber_pool->queue_job([&mod] { g_fiber_pool->queue_job([&mod, is_wheel_mod, wheel_stock_mod, wheel_custom] {
NETWORK::NETWORK_REQUEST_CONTROL_OF_ENTITY(self::veh); NETWORK::NETWORK_REQUEST_CONTROL_OF_ENTITY(self::veh);
if (selected_slot >= 0) if (selected_slot >= 0)
@ -408,7 +368,7 @@ namespace big
{ {
int& mod = wheel_mods[i]; int& mod = wheel_mods[i];
bool should_custom = false; int should_custom = false;
// bennys fix // bennys fix
if (!is_bennys) if (!is_bennys)
@ -420,7 +380,7 @@ namespace big
g_fiber_pool->queue_job([&mod] { g_fiber_pool->queue_job([&mod] {
VEHICLE::SET_VEHICLE_MOD(player_vehicle, selected_slot, mod, false); VEHICLE::SET_VEHICLE_MOD(player_vehicle, selected_slot, mod, false);
player_vehicle = 0; player_vehicle = 0;
}); });
} }
} }
@ -448,67 +408,67 @@ namespace big
ImGui::Separator(); ImGui::Separator();
components::small_text("Neon Light Options"); components::small_text("Neon Light Options");
if (ImGui::Checkbox("Headlight##headlight_en", &xenon)) if (ImGui::Checkbox("Headlight##headlight_en", (bool*)&owned_mods[MOD_XENON_LIGHTS]))
{ {
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_XENON_LIGHTS, xenon); VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_XENON_LIGHTS, owned_mods[MOD_XENON_LIGHTS]);
}); });
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Checkbox("Left", &neon_left)) if (ImGui::Checkbox("Left", (bool*)&owned_mods[MOD_NEON_LEFT_ON]))
{ {
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT, neon_left); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT, owned_mods[MOD_NEON_LEFT_ON]);
}); });
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Checkbox("Right", &neon_right)) if (ImGui::Checkbox("Right", (bool*)&owned_mods[MOD_NEON_RIGHT_ON]))
{ {
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT, neon_right); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT, owned_mods[MOD_NEON_RIGHT_ON]);
}); });
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Checkbox("Front", &neon_front)) if (ImGui::Checkbox("Front", (bool*)&owned_mods[MOD_NEON_FRONT_ON]))
{ {
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT, neon_front); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT, owned_mods[MOD_NEON_FRONT_ON]);
}); });
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Checkbox("Back", &neon_back)) if (ImGui::Checkbox("Back", (bool*)&owned_mods[MOD_NEON_BACK_ON]))
{ {
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK, neon_back); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK, owned_mods[MOD_NEON_BACK_ON]);
}); });
} }
ImGui::SameLine(); ImGui::SameLine();
components::button("Check All##neon_check_all", [] { components::button("Check All##neon_check_all", [] {
xenon = true; owned_mods[MOD_XENON_LIGHTS] = true;
neon_left = true; owned_mods[MOD_NEON_LEFT_ON] = true;
neon_right = true; owned_mods[MOD_NEON_RIGHT_ON] = true;
neon_front = true; owned_mods[MOD_NEON_FRONT_ON] = true;
neon_back = true; owned_mods[MOD_NEON_BACK_ON] = true;
VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_XENON_LIGHTS, xenon); VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_XENON_LIGHTS, owned_mods[MOD_XENON_LIGHTS]);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT, neon_left); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT, owned_mods[MOD_NEON_LEFT_ON]);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT, neon_right); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT, owned_mods[MOD_NEON_RIGHT_ON]);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT, neon_front); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT, owned_mods[MOD_NEON_FRONT_ON]);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK, neon_back); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK, owned_mods[MOD_NEON_BACK_ON]);
}); });
ImGui::SameLine(); ImGui::SameLine();
components::button("Uncheck All##neon_uncheck_all", [] { components::button("Uncheck All##neon_uncheck_all", [] {
xenon = false; owned_mods[MOD_XENON_LIGHTS] = false;
neon_left = false; owned_mods[MOD_NEON_LEFT_ON] = false;
neon_right = false; owned_mods[MOD_NEON_RIGHT_ON] = false;
neon_front = false; owned_mods[MOD_NEON_FRONT_ON] = false;
neon_back = false; owned_mods[MOD_NEON_BACK_ON] = false;
VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_XENON_LIGHTS, xenon); VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_XENON_LIGHTS, owned_mods[MOD_XENON_LIGHTS]);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT, neon_left); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT, owned_mods[MOD_NEON_LEFT_ON]);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT, neon_right); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT, owned_mods[MOD_NEON_RIGHT_ON]);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT, neon_front); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT, owned_mods[MOD_NEON_FRONT_ON]);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK, neon_back); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK, owned_mods[MOD_NEON_BACK_ON]);
}); });
ImGui::Separator(); ImGui::Separator();
@ -518,8 +478,8 @@ namespace big
static int color_type = 8; static int color_type = 8;
if ( if (
(color_to_change == 7 && !xenon) || (color_to_change == 7 && !owned_mods[MOD_XENON_LIGHTS]) ||
(color_to_change == 5 && !tiresmoke) (color_to_change == 5 && !owned_mods[MOD_TYRE_SMOKE])
) { ) {
color_to_change = 0; color_to_change = 0;
color_type = 8; color_type = 8;
@ -555,7 +515,7 @@ namespace big
color_type = 7; color_type = 7;
} }
if (!tiresmoke) if (!owned_mods[MOD_TYRE_SMOKE])
{ {
ImGui::BeginDisabled(); ImGui::BeginDisabled();
} }
@ -564,7 +524,7 @@ namespace big
color_to_change = 5; color_to_change = 5;
color_type = 8; color_type = 8;
} }
if (!tiresmoke) if (!owned_mods[MOD_TYRE_SMOKE])
{ {
ImGui::EndDisabled(); ImGui::EndDisabled();
} }
@ -575,7 +535,7 @@ namespace big
color_type = 5; color_type = 5;
} }
if (!xenon) if (!owned_mods[MOD_XENON_LIGHTS])
{ {
ImGui::BeginDisabled(); ImGui::BeginDisabled();
} }
@ -584,7 +544,7 @@ namespace big
color_to_change = 7; color_to_change = 7;
color_type = 9; color_type = 9;
} }
if (!xenon) if (!owned_mods[MOD_XENON_LIGHTS])
{ {
ImGui::EndDisabled(); ImGui::EndDisabled();
} }
@ -626,7 +586,7 @@ namespace big
{ {
VEHICLE::CLEAR_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle); VEHICLE::CLEAR_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle);
} }
VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, owned_mods[MOD_PRIMARY_COL], owned_mods[MOD_SECONDARY_COL]);
}); });
} }
@ -660,24 +620,32 @@ namespace big
// custom color // custom color
static float color[3] = { 1, 1, 1 }; static float color[3] = { 1, 1, 1 };
auto color_rgb = primary_color_rgb; auto color_r = &owned_mods[MOD_PRIMARY_COL_R];
auto color_g = &owned_mods[MOD_PRIMARY_COL_G];
auto color_b = &owned_mods[MOD_PRIMARY_COL_B];
if (color_to_change == 1) if (color_to_change == 1)
{ {
color_rgb = secondary_color_rgb; color_r = &owned_mods[MOD_SECONDARY_COL_R];
color_g = &owned_mods[MOD_SECONDARY_COL_G];
color_b = &owned_mods[MOD_SECONDARY_COL_B];
} }
else if (color_to_change == 2) else if (color_to_change == 2)
{ {
color_rgb = tire_smoke_color_rgb; color_r = &owned_mods[MOD_TIRESMOKE_COL_R];
color_g = &owned_mods[MOD_TIRESMOKE_COL_G];
color_b = &owned_mods[MOD_TIRESMOKE_COL_B];
} }
else if (color_to_change == 3) else if (color_to_change == 3)
{ {
color_rgb = neon_light_color_rgb; color_r = &owned_mods[MOD_NEON_COL_R];
color_g = &owned_mods[MOD_NEON_COL_G];
color_b = &owned_mods[MOD_NEON_COL_B];
} }
color[0] = (float)color_rgb[0] / 255; color[0] = (float)*color_r / 255;
color[1] = (float)color_rgb[1] / 255; color[1] = (float)*color_g / 255;
color[2] = (float)color_rgb[2] / 255; color[2] = (float)*color_b / 255;
if (color_to_change == 5) if (color_to_change == 5)
{ {
@ -694,9 +662,9 @@ namespace big
g_fiber_pool->queue_job([&rgb] { g_fiber_pool->queue_job([&rgb] {
VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, rgb[0], rgb[1], rgb[2]); VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, rgb[0], rgb[1], rgb[2]);
}); });
color_rgb[0] = rgb[0]; *color_r = rgb[0];
color_rgb[1] = rgb[1]; *color_g = rgb[1];
color_rgb[2] = rgb[2]; *color_b = rgb[2];
} }
} }
@ -719,9 +687,9 @@ namespace big
g_fiber_pool->queue_job([&rgb] { g_fiber_pool->queue_job([&rgb] {
VEHICLE::SET_VEHICLE_NEON_LIGHTS_COLOUR_(player_vehicle, rgb[0], rgb[1], rgb[2]); VEHICLE::SET_VEHICLE_NEON_LIGHTS_COLOUR_(player_vehicle, rgb[0], rgb[1], rgb[2]);
}); });
color_rgb[0] = rgb[0]; *color_r = rgb[0];
color_rgb[1] = rgb[1]; *color_g = rgb[1];
color_rgb[2] = rgb[2]; *color_b = rgb[2];
} }
} }
@ -733,24 +701,24 @@ namespace big
ImGui::SetNextItemWidth(214); ImGui::SetNextItemWidth(214);
if (ImGui::ColorPicker3("Custom VehColor", color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoDragDrop | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHex)) if (ImGui::ColorPicker3("Custom VehColor", color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoDragDrop | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHex))
{ {
color_rgb[0] = (int)(color[0] * 255); *color_r = (int)(color[0] * 255);
color_rgb[1] = (int)(color[1] * 255); *color_g = (int)(color[1] * 255);
color_rgb[2] = (int)(color[2] * 255); *color_b = (int)(color[2] * 255);
g_fiber_pool->queue_job([color_rgb] { g_fiber_pool->queue_job([color_r, color_g, color_b] {
switch (color_to_change) switch (color_to_change)
{ {
case 0: case 0:
VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(player_vehicle, color_rgb[0], color_rgb[1], color_rgb[2]); VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(player_vehicle, *color_r, *color_g, *color_b);
break; break;
case 1: case 1:
VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle, color_rgb[0], color_rgb[1], color_rgb[2]); VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle, *color_r, *color_g, *color_b);
break; break;
case 5: case 5:
VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, color_rgb[0], color_rgb[1], color_rgb[2]); VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, *color_r, *color_g, *color_b);
break; break;
case 8: case 8:
VEHICLE::SET_VEHICLE_NEON_LIGHTS_COLOUR_(player_vehicle, color_rgb[0], color_rgb[1], color_rgb[2]); VEHICLE::SET_VEHICLE_NEON_LIGHTS_COLOUR_(player_vehicle, *color_r, *color_g, *color_b);
break; break;
} }
}); });
@ -764,22 +732,22 @@ namespace big
switch (color_type) switch (color_type)
{ {
case 4: case 4:
selected_color = pearlescent; selected_color = owned_mods[MOD_PEARLESCENT_COL];
break; break;
case 5: case 5:
selected_color = wheel_color; selected_color = owned_mods[MOD_WHEEL_COL];
break; break;
case 6: case 6:
selected_color = interior_color; selected_color = owned_mods[MOD_INTERIOR_COL];
break; break;
case 7: case 7:
selected_color = dashboard_color; selected_color = owned_mods[MOD_DASHBOARD_COL];
break; break;
case 9: case 9:
selected_color = headlight_color; selected_color = owned_mods[MOD_XENON_COL];
break; break;
default: default:
selected_color = (color_to_change == 0) ? primary_color : secondary_color; selected_color = (color_to_change == 0) ? owned_mods[MOD_PRIMARY_COL] : owned_mods[MOD_SECONDARY_COL];
} }
if (color_type != 9) if (color_type != 9)
@ -797,15 +765,15 @@ namespace big
{ {
if (color_to_change == 0) if (color_to_change == 0)
{ {
primary_color = COLOR_CHROME; owned_mods[MOD_PRIMARY_COL] = COLOR_CHROME;
} }
else else
{ {
secondary_color = COLOR_CHROME; owned_mods[MOD_SECONDARY_COL] = COLOR_CHROME;
} }
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, owned_mods[MOD_PRIMARY_COL], owned_mods[MOD_SECONDARY_COL]);
}); });
} }
break; break;
@ -820,15 +788,15 @@ namespace big
if (color_to_change == 0) if (color_to_change == 0)
{ {
primary_color = color; owned_mods[MOD_PRIMARY_COL] = color;
} }
else else
{ {
secondary_color = color; owned_mods[MOD_SECONDARY_COL] = color;
} }
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, owned_mods[MOD_PRIMARY_COL], owned_mods[MOD_SECONDARY_COL]);
}); });
} }
@ -845,15 +813,15 @@ namespace big
if (color_to_change == 0) if (color_to_change == 0)
{ {
primary_color = color; owned_mods[MOD_PRIMARY_COL] = color;
} }
else else
{ {
secondary_color = color; owned_mods[MOD_SECONDARY_COL] = color;
} }
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, owned_mods[MOD_PRIMARY_COL], owned_mods[MOD_SECONDARY_COL]);
}); });
} }
@ -870,15 +838,15 @@ namespace big
if (color_to_change == 0) if (color_to_change == 0)
{ {
primary_color = color; owned_mods[MOD_PRIMARY_COL] = color;
} }
else else
{ {
secondary_color = color; owned_mods[MOD_SECONDARY_COL] = color;
} }
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, owned_mods[MOD_PRIMARY_COL], owned_mods[MOD_SECONDARY_COL]);
}); });
} }
} }
@ -891,10 +859,10 @@ namespace big
if (ImGui::Selectable(name.c_str(), selected_color == color)) if (ImGui::Selectable(name.c_str(), selected_color == color))
{ {
selected_color = color; selected_color = color;
pearlescent = color; owned_mods[MOD_PEARLESCENT_COL] = color;
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_EXTRA_COLOURS(player_vehicle, pearlescent, wheel_color); VEHICLE::SET_VEHICLE_EXTRA_COLOURS(player_vehicle, owned_mods[MOD_PEARLESCENT_COL], owned_mods[MOD_WHEEL_COL]);
}); });
} }
} }
@ -907,10 +875,10 @@ namespace big
if (ImGui::Selectable(name.c_str(), selected_color == color)) if (ImGui::Selectable(name.c_str(), selected_color == color))
{ {
selected_color = color; selected_color = color;
wheel_color = color; owned_mods[MOD_WHEEL_COL] = color;
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_EXTRA_COLOURS(player_vehicle, pearlescent, wheel_color); VEHICLE::SET_VEHICLE_EXTRA_COLOURS(player_vehicle, owned_mods[MOD_PEARLESCENT_COL], owned_mods[MOD_WHEEL_COL]);
}); });
} }
} }
@ -923,10 +891,10 @@ namespace big
if (ImGui::Selectable(name.c_str(), selected_color == color)) if (ImGui::Selectable(name.c_str(), selected_color == color))
{ {
selected_color = color; selected_color = color;
interior_color = color; owned_mods[MOD_INTERIOR_COL] = color;
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_INTERIOR_COLOR_(player_vehicle, interior_color); VEHICLE::SET_VEHICLE_INTERIOR_COLOR_(player_vehicle, owned_mods[MOD_INTERIOR_COL]);
}); });
} }
} }
@ -939,10 +907,10 @@ namespace big
if (ImGui::Selectable(name.c_str(), selected_color == color)) if (ImGui::Selectable(name.c_str(), selected_color == color))
{ {
selected_color = color; selected_color = color;
dashboard_color = color; owned_mods[MOD_DASHBOARD_COL] = color;
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_DASHBOARD_COLOR_(player_vehicle, dashboard_color); VEHICLE::SET_VEHICLE_DASHBOARD_COLOR_(player_vehicle, owned_mods[MOD_DASHBOARD_COL]);
}); });
} }
} }
@ -955,10 +923,10 @@ namespace big
if (ImGui::Selectable(name.c_str(), selected_color == color)) if (ImGui::Selectable(name.c_str(), selected_color == color))
{ {
selected_color = color; selected_color = color;
headlight_color = color; owned_mods[MOD_XENON_COL] = color;
g_fiber_pool->queue_job([] { g_fiber_pool->queue_job([] {
VEHICLE::SET_VEHICLE_XENON_LIGHTS_COLOR_(player_vehicle, headlight_color); VEHICLE::SET_VEHICLE_XENON_LIGHTS_COLOR_(player_vehicle, owned_mods[MOD_XENON_COL]);
}); });
} }
} }

View File

@ -136,12 +136,7 @@ namespace big
spawn_plate = personal_veh->get_plate(); spawn_plate = personal_veh->get_plate();
} }
auto veh = vehicle::clone(veh_data, spawn_location, spawn_heading); auto veh = vehicle::clone_from_vehicle_data(veh_data, spawn_location, spawn_heading);
if (g->clone_pv.spawn_inside)
{
vehicle::telport_into_veh(veh);
}
if (g->clone_pv.spawn_maxed) if (g->clone_pv.spawn_maxed)
{ {
@ -149,6 +144,11 @@ namespace big
} }
vehicle::set_plate(veh, spawn_plate); vehicle::set_plate(veh, spawn_plate);
if (g->clone_pv.spawn_inside)
{
vehicle::teleport_into_vehicle(veh);
}
} }
else else
{ {

View File

@ -104,11 +104,6 @@ namespace big
const Vehicle veh = vehicle::spawn(item.hash, spawn_location, spawn_heading); const Vehicle veh = vehicle::spawn(item.hash, spawn_location, spawn_heading);
if (g->spawn.spawn_inside)
{
vehicle::telport_into_veh(veh);
}
if (g->spawn.spawn_maxed) if (g->spawn.spawn_maxed)
{ {
vehicle::max_vehicle(veh); vehicle::max_vehicle(veh);
@ -116,6 +111,11 @@ namespace big
vehicle::set_plate(veh, plate); vehicle::set_plate(veh, plate);
if (g->spawn.spawn_inside)
{
vehicle::teleport_into_vehicle(veh);
}
g_vehicle_preview_service->stop_preview(); g_vehicle_preview_service->stop_preview();
}); });
ImGui::PopID(); ImGui::PopID();