From 9b0bae0272a32e3596458522bd643abbe45d00c1 Mon Sep 17 00:00:00 2001 From: Yimura Date: Fri, 21 May 2021 14:09:28 +0200 Subject: [PATCH] feat(Vehicle): Added bring vehicle button --- BigBaseV2/src/gui/window/main/tab_vehicle.cpp | 24 +++++++++++++++++++ BigBaseV2/src/util/blip.hpp | 23 ++++++++++++++++++ BigBaseV2/src/util/vehicle.hpp | 16 +++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 BigBaseV2/src/util/blip.hpp diff --git a/BigBaseV2/src/gui/window/main/tab_vehicle.cpp b/BigBaseV2/src/gui/window/main/tab_vehicle.cpp index c56e33e7..2c569db4 100644 --- a/BigBaseV2/src/gui/window/main/tab_vehicle.cpp +++ b/BigBaseV2/src/gui/window/main/tab_vehicle.cpp @@ -1,5 +1,11 @@ #include "core/data/speedo_meters.hpp" +#include "fiber_pool.hpp" #include "gui/window/main/tabs.hpp" +#include "script.hpp" +#include "util/blip.hpp" +#include "util/entity.hpp" +#include "util/notify.hpp" +#include "util/vehicle.hpp" namespace big { @@ -9,6 +15,24 @@ namespace big { if (ImGui::BeginTabItem("Vehicle")) { + if (ImGui::Button("Bring Personal Vehicle")) + { + QUEUE_JOB_BEGIN_CLAUSE() + { + Vector3 location; + if (!blip::get_blip_location(location, 225, 0)) return notify::above_map("No personal vehicle found, was it destroyed?"); + + Vehicle veh = vehicle::get_closest_to_location(location, 5.f); + if (veh == 0) return notify::above_map("Invalid vehicle handle..."); + + location = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true); + + entity::take_control_of(veh); + + vehicle::bring(veh, location); + }QUEUE_JOB_END_CLAUSE + } + if (ImGui::TreeNode("Speedo Meter")) { SpeedoMeter selected = g.vehicle.speedo_meter; diff --git a/BigBaseV2/src/util/blip.hpp b/BigBaseV2/src/util/blip.hpp new file mode 100644 index 00000000..df8da576 --- /dev/null +++ b/BigBaseV2/src/util/blip.hpp @@ -0,0 +1,23 @@ +#pragma once +#include "gta/enums.hpp" +#include "natives.hpp" +#include "script.hpp" + +namespace big::blip +{ + inline bool get_blip_location(Vector3 &location, int sprite, int color = -1) + { + Blip blip; + for (blip = HUD::GET_FIRST_BLIP_INFO_ID(sprite); + HUD::DOES_BLIP_EXIST(blip) && + color != -1 && HUD::GET_BLIP_COLOUR(blip); + blip = HUD::GET_NEXT_BLIP_INFO_ID(sprite) + ) script::get_current()->yield(); + + if (!HUD::DOES_BLIP_EXIST(blip) || (color != -1 && HUD::GET_BLIP_COLOUR(blip) != color)) return false; + + location = HUD::GET_BLIP_COORDS(blip); + + return true; + } +} \ No newline at end of file diff --git a/BigBaseV2/src/util/vehicle.hpp b/BigBaseV2/src/util/vehicle.hpp index 5b6533b6..b3776e52 100644 --- a/BigBaseV2/src/util/vehicle.hpp +++ b/BigBaseV2/src/util/vehicle.hpp @@ -7,6 +7,22 @@ namespace big::vehicle { + inline void bring(Vehicle veh, Vector3 location, bool put_in = true) + { + ENTITY::SET_ENTITY_COORDS(veh, location.x, location.y, location.z + 1.f, 0, 0, 0, 1); + + if (put_in) + { + script::get_current()->yield(100ms); + PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, -1); + } + } + + inline Vehicle get_closest_to_location(Vector3 location, float range, int flags = 70) + { + return VEHICLE::GET_CLOSEST_VEHICLE(location.x, location.y, location.z, range, 0, flags); + } + inline int spawn(const char* model, Vector3 location, float heading) { Hash hash = rage::joaat(model);