60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
![]() |
#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;
|
||
|
}
|
||
|
}
|