--[[

В чем проблема?
```lua
-- Код номер 1
local font = renderCreateFont('Tahoma', 10, 4)
local nodes = {}
local nodeCount = 255
local startNodeIndex = 1
local goalNodeIndex = 5
function main()
    while not isSampAvailable() do
        wait(0)
    end

    sampRegisterChatCommand('get_node_in_stream', function()
        local fx, fy, fz = getCharCoordinates(PLAYER_PED)
        nodes = {}
        for i = 1, nodeCount do
            local nx, ny, nz = getNthClosestCarNode(fx, fy, fz, i)
            table.insert(nodes, {
                x = nx,
                y = ny,
                z = nz
            })
        end

        table.sort(nodes, function(a, b)
            local distA = getDistanceBetweenCoords3d(fx, fy, fz, a.x, a.y, a.z)
            local distB = getDistanceBetweenCoords3d(fx, fy, fz, b.x, b.y, b.z)
            return distA < distB
        end)

        local start = nodes[startNodeIndex]
        local goal = nodes[goalNodeIndex]
        local path = AStar(start, goal, nodes)
        if path then
            lua_thread.create(function()
                while true do
                    wait(0)
                    for i, node in ipairs(path) do
                        local result, sx, sy = convert3DCoordsToScreenEx(node.x, node.y, node.z)
                        if result and isPointOnScreen(node.x, node.y, node.z, 5) then renderFontDrawText(font, 'node #' .. i, sx, sy, 0xFFFFFFFF, 0x90000000) end
                    end
                end
            end)
        else
            print("Path not found")
        end
    end)

    sampRegisterChatCommand('set_nodes', function(params)
        local startIdx, goalIdx = params:match("(%d+)%s+(%d+)")
        if startIdx and goalIdx then
            startNodeIndex = tonumber(startIdx)
            goalNodeIndex = tonumber(goalIdx)
            print("Start node set to: " .. startNodeIndex)
            print("Goal node set to: " .. goalNodeIndex)
        else
            print("Invalid input. Use: /set_nodes <start_index> <goal_index>")
        end
    end)

    while true do
        wait(0)
    end
end

local function get_neighbors(node, nodes)
    local neighbors = {}
    for _, neighbor in ipairs(nodes) do
        if neighbor ~= node then table.insert(neighbors, neighbor) end
    end
    return neighbors
end

local function reconstruct_path(cameFrom, current)
    local total_path = {current}
    while cameFrom[current] do
        current = cameFrom[current]
        table.insert(total_path, 1, current)
    end
    return total_path
end

function AStar(start, goal, nodes)
    local closedSet = {}
    local openSet = {start}
    local cameFrom = {}
    start.g = 0
    start.h = getDistanceBetweenCoords3d(start.x, start.y, start.z, goal.x, goal.y, goal.z)
    start.f = start.g + start.h
    while #openSet > 0 do
        table.sort(openSet, function(a, b) return a.f < b.f end)
        local current = table.remove(openSet, 1)
        if current == goal then return reconstruct_path(cameFrom, current) end
        table.insert(closedSet, current)
        for _, neighbor in ipairs(get_neighbors(current, nodes)) do
            if not tableContains(closedSet, neighbor) then
                local tentative_g_score = current.g + getDistanceBetweenCoords3d(current.x, current.y, current.z, neighbor.x, neighbor.y, neighbor.z)
                if not tableContains(openSet, neighbor) or tentative_g_score < neighbor.g then
                    cameFrom[neighbor] = current
                    neighbor.g = tentative_g_score
                    neighbor.h = getDistanceBetweenCoords3d(neighbor.x, neighbor.y, neighbor.z, goal.x, goal.y, goal.z)
                    neighbor.f = neighbor.g + neighbor.h
                    if not tableContains(openSet, neighbor) then table.insert(openSet, neighbor) end
                end
            end
        end
    end
    return false
end

function tableContains(tbl, element)
    for _, value in pairs(tbl) do
        if value == element then return true end
    end
    return false
end
```
Этот код под номером 1, получает только 2 ноды
```lua
-- Код номер 2
local font = renderCreateFont('Tahoma', 10, 4)
local nodes = {}
local nodeCount = 255
function main()
    while not isSampAvailable() do
        wait(0)
    end

    sampRegisterChatCommand('get_node_in_stream', function()
        local fx, fy, fz = getCharCoordinates(PLAYER_PED)
        nodes = {}
        for i = 1, nodeCount do
            local nx, ny, nz = getNthClosestCarNode(fx, fy, fz, i)
            table.insert(nodes, {nx, ny, nz})
        end

        local sortedNodes = {}
        local currentNode = {fx, fy, fz}
        while #nodes > 0 do
            local nearestIndex = 1
            local nearestDistance = getDistanceBetweenCoords3d(currentNode[1], currentNode[2], currentNode[3], nodes[1][1], nodes[1][2], nodes[1][3])
            for i = 2, #nodes do
                local distance = getDistanceBetweenCoords3d(currentNode[1], currentNode[2], currentNode[3], nodes[i][1], nodes[i][2], nodes[i][3])
                if distance < nearestDistance then
                    nearestIndex = i
                    nearestDistance = distance
                end
            end

            table.insert(sortedNodes, nodes[nearestIndex])
            currentNode = nodes[nearestIndex]
            table.remove(nodes, nearestIndex)
        end

        nodes = sortedNodes
        lua_thread.create(function()
            while true do
                wait(0)
                for i = 1, #nodes do
                    local result, sx, sy = convert3DCoordsToScreenEx(nodes[i][1], nodes[i][2], nodes[i][3])
                    if result and isPointOnScreen(nodes[i][1], nodes[i][2], nodes[i][3], 5) then renderFontDrawText(font, 'node #' .. i, sx, sy, 0xFFFFFFFF, 0x90000000) end
                end
            end
        end)
    end)

    while true do
        wait(0)
    end
end
```
А код номер 2, получает все доступные ноды.
Как сделать чтобы код 1 тоже получал все ноды, а не только 2.]]