diff --git a/BigBaseV2/src/features/teleport.cpp b/BigBaseV2/src/features/teleport.cpp index 6ad2635a..52a6f7e9 100644 --- a/BigBaseV2/src/features/teleport.cpp +++ b/BigBaseV2/src/features/teleport.cpp @@ -2,24 +2,16 @@ namespace big::features::teleport { - // Teleport the player (with/without car to a waypoint) - bool waypoint() + Vector3 get_ground_at_3d_coord(Vector3 location) { - Ped player = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId); - - Blip blipHandle = HUD::GET_FIRST_BLIP_INFO_ID(8); - if (!HUD::DOES_BLIP_EXIST(blipHandle)) return false; - - Vector3 location = HUD::GET_BLIP_COORDS(blipHandle); float groundZ; - - UINT16 attempts = 10; - for (UINT16 i = 0; i < attempts; i++) + uint16_t attempts = 10; + for (uint16_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. if (i) { - for (UINT16 z = 0; z < 1000; z += 100) + for (uint16_t z = 0; z < 1000; z += 100) { STREAMING::REQUEST_COLLISION_AT_COORD(location.x, location.y, z); @@ -39,6 +31,21 @@ namespace big::features::teleport script::get_current()->yield(); } + return location; + } + + // Teleport the player (with/without car to a waypoint) + bool waypoint() + { + Ped player = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId); + + Blip blipHandle = HUD::GET_FIRST_BLIP_INFO_ID(8); + if (!HUD::DOES_BLIP_EXIST(blipHandle)) return false; + + Vector3 location = HUD::GET_BLIP_COORDS(blipHandle); + + location = get_ground_at_3d_coord(location); + PED::SET_PED_COORDS_KEEP_VEHICLE(player, location.x, location.y, location.z); return true; diff --git a/BigBaseV2/src/features/teleport.hpp b/BigBaseV2/src/features/teleport.hpp index bdd623bc..a5567c55 100644 --- a/BigBaseV2/src/features/teleport.hpp +++ b/BigBaseV2/src/features/teleport.hpp @@ -6,6 +6,7 @@ namespace big::features::teleport { bool bring_blip(int blipSprite, int blipColor, int flag = 70); + Vector3 get_ground_at_3d_coord(Vector3 location); bool teleport_to_blip(int blipSprite, int blipColor = -1); bool waypoint(); } \ No newline at end of file