Skip to content

Instantly share code, notes, and snippets.

@xXTurnerLP
Last active February 25, 2024 19:42
Show Gist options
  • Save xXTurnerLP/d78592d0fe15bd25d4dd1fba931154ba to your computer and use it in GitHub Desktop.
Save xXTurnerLP/d78592d0fe15bd25d4dd1fba931154ba to your computer and use it in GitHub Desktop.
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)
repeat
Citizen.Wait(50)
_, gz = GetGroundZFor_3dCoord(blipPos.x, blipPos.y, z, true)
until gz ~= 0
SetEntityCoords(PlayerPedId(), blipPos.x, blipPos.y, gz, true, false, false, false)
FreezeEntityPosition(PlayerPedId(), false)
end, false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment