diff --git a/BigBaseV2/src/gui/window/main/tab_teleport.cpp b/BigBaseV2/src/gui/window/main/tab_teleport.cpp new file mode 100644 index 00000000..292dedb0 --- /dev/null +++ b/BigBaseV2/src/gui/window/main/tab_teleport.cpp @@ -0,0 +1,22 @@ +#include "tabs.hpp" +#include "fiber_pool.hpp" +#include "util/teleport.hpp" + +namespace big +{ + void tab_main::tab_teleport() + { + if (ImGui::BeginTabItem("Teleport")) + { + if (ImGui::Button("Waypoint")) + { + QUEUE_JOB_BEGIN_CLAUSE() + { + teleport::to_waypoint(); + }QUEUE_JOB_END_CLAUSE + } + + ImGui::EndTabItem(); + } + } +} \ No newline at end of file diff --git a/BigBaseV2/src/gui/window/main/tabs.hpp b/BigBaseV2/src/gui/window/main/tabs.hpp index 9b66959e..a66790f9 100644 --- a/BigBaseV2/src/gui/window/main/tabs.hpp +++ b/BigBaseV2/src/gui/window/main/tabs.hpp @@ -10,5 +10,6 @@ namespace big static void tab_spawn(); static void tab_vehicle(); static void tab_weapons(); + static void tab_teleport(); }; } \ No newline at end of file diff --git a/BigBaseV2/src/gui/window/window_main.cpp b/BigBaseV2/src/gui/window/window_main.cpp index bcd65311..ba4675ba 100644 --- a/BigBaseV2/src/gui/window/window_main.cpp +++ b/BigBaseV2/src/gui/window/window_main.cpp @@ -12,6 +12,7 @@ namespace big ImGui::BeginTabBar("tabbar"); tab_main::tab_self(); tab_main::tab_spawn(); + tab_main::tab_teleport(); tab_main::tab_vehicle(); tab_main::tab_weapons(); ImGui::EndTabBar(); diff --git a/BigBaseV2/src/util/all.hpp b/BigBaseV2/src/util/all.hpp index d8232160..3547ab9d 100644 --- a/BigBaseV2/src/util/all.hpp +++ b/BigBaseV2/src/util/all.hpp @@ -1,5 +1,7 @@ #pragma once +#include "blip.hpp" #include "entity.hpp" #include "math.hpp" #include "notify.hpp" +#include "teleport.hpp" #include "vehicle.hpp" \ No newline at end of file diff --git a/BigBaseV2/src/util/teleport.hpp b/BigBaseV2/src/util/teleport.hpp new file mode 100644 index 00000000..9da6201d --- /dev/null +++ b/BigBaseV2/src/util/teleport.hpp @@ -0,0 +1,60 @@ +#include "blip.hpp" +#include "notify.hpp" + +namespace big::teleport +{ + inline bool load_ground_at_3dcoord(Vector3& location) + { + float groundZ; + const uint8_t attempts = 10; + + for (uint8_t i = 0; i < attempts; i++) + { + // Only request a collision after the first try failed because the location might already be loaded on first attempt. + for (uint16_t z = 0; i && z < 1000; z += 100) + { + STREAMING::REQUEST_COLLISION_AT_COORD(location.x, location.y, (float)z); + + script::get_current()->yield(); + } + + if (MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, 1000.f, &groundZ, false, false)) + { + location.z = groundZ + 1.f; + + return true; + } + + script::get_current()->yield(); + } + + location.z = 1000.f; + + return false; + } + + inline bool to_blip(int sprite, int color = -1) + { + Vector3 location; + + if (!blip::get_blip_location(location, sprite, color)) + return false; + + load_ground_at_3dcoord(location); + + PED::SET_PED_COORDS_KEEP_VEHICLE(PLAYER::PLAYER_PED_ID(), location.x, location.y, location.z); + + return true; + } + + inline bool to_waypoint() + { + if (!to_blip((int)BlipIcons::Waypoint)) + { + notify::above_map("Failed to find waypoint position"); + + return false; + } + return true; + } +} \ No newline at end of file