get
Retrieves a waypoint instance by its ID. Returns the waypoint data and DUI reference if the waypoint exists.
Parameters
id(number): The waypoint ID returned fromcreate
Returns
waypoint(WaypointInstance?): The waypoint instance, ornilif not foundid(number): The waypoint's unique identifierdata(WaypointData): The waypoint's configuration datadui(Dui): The DUI instance used for renderingactive(boolean): Whether the waypoint is currently active
Examples
Check Waypoint Exists
local id = exports.sleepless_waypoints:create({
coords = vec3(100.0, 200.0, 30.0),
type = 'checkpoint',
label = 'TARGET',
})
-- Check if waypoint still exists
local waypoint = exports.sleepless_waypoints:get(id)
if waypoint then
print('Waypoint exists at:', waypoint.data.coords)
print('Active:', waypoint.active)
else
print('Waypoint not found')
endGet Waypoint Properties
local waypoint = exports.sleepless_waypoints:get(waypointId)
if waypoint and waypoint.active then
local data = waypoint.data
print('Type:', data.type)
print('Color:', data.color)
print('Label:', data.label)
print('Draw Distance:', data.drawDistance)
endCalculate Distance to Waypoint
local waypoint = exports.sleepless_waypoints:get(waypointId)
if waypoint then
local playerPos = GetEntityCoords(cache.ped)
local distance = #(playerPos - waypoint.data.coords)
print('Distance to waypoint:', distance)
end