- 123
- 5
I have this Lua code to teleport to checkpoints, but it works with short-distance teleports. However, for long-distance teleports, it teleports to a stadium checkpoint, and I don't want that! How to fix it?
Lua:
if aim.CheckBox.teste12[0] then
local vector3d = require("vector3d")
local result, position = (function(position, radius, isRace)
local result, isFind = vector3d(0, 0, 0), false
for id = 0, 31 do
local address = isRace and (0xC7F168 + id * 56) or (0xC7DD88 + id * 160)
local marker = vector3d(
representIntAsFloat(readMemory(address + 0, 4, false)),
representIntAsFloat(readMemory(address + 4, 4, false)),
representIntAsFloat(readMemory(address + 8, 4, false))
)
if marker.x ~= 0 and marker.y ~= 0 and marker.z ~= 0 then
local distance = (marker - position):length()
if distance < radius then
result = marker
isFind = true
radius = distance
end
end
end
return isFind, result
end)(vector3d(getCharCoordinates(playerPed)), 20000, false)
if result then
setCharCoordinates(playerPed, position.x, position.y, position.z)
end
end