function coordmaster(x, y, z, step, depth, depth_bool)
lua_thread.create(function()
freezeCharPosition(playerPed, true)
repeat
wait(50)
local mx, my, mz = getCharCoordinates(playerPed)
local floor = math.floor
if floor(mx) ~= floor(x) and floor(my) ~= floor(y) then
if floor(mz) ~= floor(depth) then
if math.abs(depth - mz) < step then
setCharCoordinatesNoOffset(playerPed, mx, my, depth)
else
if mz < depth then
setCharCoordinatesNoOffset(playerPed, mx, my, mz + step)
else
setCharCoordinatesNoOffset(playerPed, mx, my, mz - step)
end
end
else
if getDistanceBetweenCoords3d(mx, my, mz, x, y, depth) < step then
setCharCoordinatesNoOffset(playerPed, x, y, depth)
else
local angle = get_camera_direcion(x, y)
setCharHeading(playerPed, angle)
local mx = mx + step * math.sin(-math.rad(angle))
local my = my + step * math.cos(-math.rad(angle))
local mz = depth
setCharCoordinatesNoOffset(playerPed, mx, my, mz)
end
end
else
setCharCoordinatesNoOffset(playerPed, x, y, mz - step)
end
local dist = getDistanceBetweenCoords3d(mx, my, mz, x, y, z)
if dist < 5 then
setCharCoordinatesNoOffset(playerPed, x, y, z)
break
end
if math.random(1, 100) > 80 then sampForceOnfootSync() end
until false
freezeCharPosition(playerPed, false)
end)
end