Skip to content

Instantly share code, notes, and snippets.

@xXTurnerLP
xXTurnerLP / tp.lua
Last active February 25, 2024 19:42
FiveM Precise waypoint teleport script. Always teleports at the top most level, so if you mark a building it will teleport to the top of that building (No permissions, client side)
RegisterCommand("tp", function(source, args, rawCommand)
local waypointBlip = GetFirstBlipInfoId(GetWaypointBlipEnumId())
local blipPos = GetBlipInfoIdCoord(waypointBlip) -- GetGpsWaypointRouteEnd(false, 0, 0)
local z = GetHeightmapTopZForPosition(blipPos.x, blipPos.y)
local _, gz = GetGroundZFor_3dCoord(blipPos.x, blipPos.y, z, true)
SetEntityCoords(PlayerPedId(), blipPos.x, blipPos.y, z, true, false, false, false)
FreezeEntityPosition(PlayerPedId(), true)