From f0d1639884db04a15354e93dbd36aa24f8d745fa Mon Sep 17 00:00:00 2001 From: xM4ddy Date: Mon, 16 May 2022 15:33:43 -0400 Subject: [PATCH] Should be working. --- BigBaseV2/src/backend/backend.cpp | 1 + BigBaseV2/src/backend/looped/looped.hpp | 1 + .../src/backend/looped/vehicle/seatbelt.cpp | 21 +++++++++++++++++++ BigBaseV2/src/core/globals.hpp | 3 +++ BigBaseV2/src/views/vehicle/view_vehicle.cpp | 2 ++ 5 files changed, 28 insertions(+) create mode 100644 BigBaseV2/src/backend/looped/vehicle/seatbelt.cpp diff --git a/BigBaseV2/src/backend/backend.cpp b/BigBaseV2/src/backend/backend.cpp index b80709f0..683fee0c 100644 --- a/BigBaseV2/src/backend/backend.cpp +++ b/BigBaseV2/src/backend/backend.cpp @@ -94,6 +94,7 @@ namespace big looped::vehicle_instant_brake(); looped::vehicle_is_targetable(); looped::vehicle_rainbow_paint(); + looped::vehicle_seatbelt(); looped::vehicle_speedo_meter(); }QUEUE_JOB_END_CLAUSE diff --git a/BigBaseV2/src/backend/looped/looped.hpp b/BigBaseV2/src/backend/looped/looped.hpp index 72dd3664..b7c60df3 100644 --- a/BigBaseV2/src/backend/looped/looped.hpp +++ b/BigBaseV2/src/backend/looped/looped.hpp @@ -45,6 +45,7 @@ namespace big static void vehicle_is_targetable(); static void vehicle_ls_customs(); static void vehicle_rainbow_paint(); + static void vehicle_seatbelt(); static void vehicle_speedo_meter(); static void weapons_ammo_special_type(); diff --git a/BigBaseV2/src/backend/looped/vehicle/seatbelt.cpp b/BigBaseV2/src/backend/looped/vehicle/seatbelt.cpp new file mode 100644 index 00000000..79d3906a --- /dev/null +++ b/BigBaseV2/src/backend/looped/vehicle/seatbelt.cpp @@ -0,0 +1,21 @@ +#include "backend/looped/looped.hpp" +#include "natives.hpp" + +namespace big +{ + static bool b_last_seatbelt = false; + + void looped::vehicle_seatbelt() + { + bool b_seatbelt = g->vehicle.seatbelt; + + if (b_seatbelt || (!b_seatbelt && b_seatbelt != b_last_seatbelt)) + { + PED::SET_PED_CONFIG_FLAG(self::ped, 32, g->vehicle.seatbelt); + + PED::SET_PED_CAN_BE_KNOCKED_OFF_VEHICLE(self::ped, g->vehicle.seatbelt); + + b_last_seatbelt = g->vehicle.seatbelt; + } + } +} diff --git a/BigBaseV2/src/core/globals.hpp b/BigBaseV2/src/core/globals.hpp index 44796fde..22664e69 100644 --- a/BigBaseV2/src/core/globals.hpp +++ b/BigBaseV2/src/core/globals.hpp @@ -218,6 +218,7 @@ namespace big bool ls_customs = false; // don't save this to disk bool pv_teleport_into = false; int rainbow_paint = 0; + bool seatbelt = false; speedo_meter speedo_meter{}; fly fly{}; }; @@ -474,6 +475,7 @@ namespace big this->vehicle.is_targetable = j["vehicle"]["is_targetable"]; this->vehicle.pv_teleport_into = j["vehicle"]["pv_teleport_into"]; this->vehicle.rainbow_paint = j["vehicle"]["rainbow_paint"]; + this->vehicle.seatbelt = j["vehicle"]["seatbelt"]; this->vehicle.speedo_meter.type = (SpeedoMeter)j["vehicle"]["speedo_meter"]["type"]; this->vehicle.speedo_meter.left_side = j["vehicle"]["speedo_meter"]["left_side"]; @@ -704,6 +706,7 @@ namespace big { "is_targetable", this->vehicle.is_targetable }, { "pv_teleport_into", this->vehicle.pv_teleport_into }, { "rainbow_paint", this->vehicle.rainbow_paint }, + { "seatbelt", this->vehicle.seatbelt }, { "speedo_meter", { { "type", (int)this->vehicle.speedo_meter.type }, diff --git a/BigBaseV2/src/views/vehicle/view_vehicle.cpp b/BigBaseV2/src/views/vehicle/view_vehicle.cpp index 62909064..01931fb7 100644 --- a/BigBaseV2/src/views/vehicle/view_vehicle.cpp +++ b/BigBaseV2/src/views/vehicle/view_vehicle.cpp @@ -20,6 +20,8 @@ namespace big ImGui::SameLine(); ImGui::BeginGroup(); + ImGui::Checkbox("Seatbelt", &g->vehicle.seatbelt); + components::button("Repair", [] { vehicle::repair(self::veh);