как реализовать актёра, ходящего по записанному пути?

g305noobo

Известный
Автор темы
221
203
Версия MoonLoader
.026-beta
ку, хочу реализовать простенького актера, для которого можно будет записать путь, а затем его воспроизвести. вопрос только в том, как всё это воспроизвести, записываю я так:
Lua:
function record_route()
    local function write_route(file)
        local f, err = io.open(getWorkingDirectory() .. "/" .. file, "w")
        local json  = encodeJson(onfoot)
        f:write(json)
        f:close()
    end
    lua_thread.create(function()
        recording = true
        sampAddChatMessage('Recording started', 0xFF0000)
        
        while recording do wait(0)
            local x, y, z = getCharCoordinates(PLAYER_PED)
            local entry = {position = {x = x, y = y, z = z}, is_sprint = isKeyDown(0x20), is_jumping = false}

            if isKeyDown(0xA0) then
                entry.is_jumping = true
                while isButtonPressed(PLAYER_HANDLE, 14) do wait(0) end
                wait(600)
            end

            local text = entry.is_sprint and 'SPRINT' or 'no SPRINT'
            text = entry.is_jumping and 'JUMP + ' .. text or text
            printStringNow('Recording '..text..' ~y~X: '..math.floor(x)..' Y: '..math.floor(y)..'', 1000)

            table.insert(onfoot, entry)
        end
        write_route("recording.txt")
    end)
end
а вопроизвожу вот так
Lua:
function play_route(ped, file)
    local f = io.open(getWorkingDirectory() .. "/" .. file)
    local data = decodeJson(f:read('*a'))
    f:close()
    lua_thread.create(function()
        local b = false
        for i, entry in ipairs(data) do
            if not b then setCharCoordinates(ped, entry.position.x, entry.position.y, entry.position.z) b = true wait(1000) end

            if entry.is_jumping then
                taskGoStraightToCoord(ped, entry.position.x, entry.position.y, entry.position.z, 6, -1)
                taskJump(ped, true)
                sampAddChatMessage('прыгаю', -1)
                taskJump(ped, false)
                wait(600)
            else
                setCharCoordinates(ped, entry.position.x, entry.position.y, entry.position.z)
                if entry.is_sprint then
                    taskGoStraightToCoord(ped, entry.position.x, entry.position.y, entry.position.z, 7, -1)
                    sampAddChatMessage('бегу', -1)
                else
                    taskGoStraightToCoord(ped, entry.position.x, entry.position.y, entry.position.z, 6, -1)
                    sampAddChatMessage('иду', -1)
                end
            end
        end
    end)
end

тут прикол в том, что функция taskGoStraightToCoord работает слегка не так как нужно, она ведь в целом для другого нужна.
за идеи и предложения заранее спс