Сократи количество строк, а так же я люблю квадратные скобки в коде, сделай так чтобы их было больше:
```lua
local VK_S, VK_A, VK_D, VK_F5 = 0x53, 0x41, 0x44, 0x74

local font = renderCreateFont('Arial', 8, 8)

local DrivingAssistant = {}
DrivingAssistant.__index = DrivingAssistant

function DrivingAssistant:new()
    local driver = setmetatable({}, self)
    driver.drivingEnabled = false
    driver.lastTurnDirection = nil
    driver.userInputMultiplier = 5
    return driver
end

function DrivingAssistant:toggleDriving()
    self.drivingEnabled = not self.drivingEnabled
    local message = self.drivingEnabled and 'Ассистент двух колес включен.' or 'Ассистент двух колес выключен.'
    sampAddChatMessage(message, -1)
end

function DrivingAssistant:processDriving()
    if not isCharInAnyCar(PLAYER_PED) then
        sampAddChatMessage('Вы должны сесть на байк.', -1)
        return
    end

    local playerData = self:getPlayerCoordsAndHeading()
    local playerCoords, playerHeading = playerData.coords, playerData.heading
    local radOffset = math.rad(-playerHeading)
    local offsetX, offsetY = self:getOffsetCoords(playerCoords, radOffset)

    local obstacleInfo, allLinesOccupied = self:detectObstacles(playerCoords, playerHeading, radOffset, offsetX, offsetY)
    self:handleObstacles(obstacleInfo, allLinesOccupied)
end

function DrivingAssistant:detectObstacles(playerCoords, playerHeading, radOffset, offsetX, offsetY)
    local obstacleInfo = {
        detected = {left = false, right = false, front = false, center = false},
        specific = {}
    }

    local pitch = math.rad(getCarPitch(getCarCharIsUsing(PLAYER_PED)))
    local allLinesOccupied = true

    for i = -4, 4 do
        local radian = math.rad(-playerHeading + 2 * i)
        local sinRadian, cosRadian = math.sin(radian), math.cos(radian)
        local multiplier = self:getMultiplier(i)
        local targetX, targetY, targetZ = self:getTargetCoords(offsetX, offsetY, pitch, multiplier, sinRadian, cosRadian)
        local obstacle = self:isObstacleInFront(offsetX, offsetY, targetX, targetY, targetZ)

        if i ~= 0 then
            allLinesOccupied = allLinesOccupied and obstacle
        end

        local color = obstacle and 0xFFFF0000 or 0xFFFFFFFF

        self:renderLine3D(offsetX, offsetY, 0.0, targetX, targetY, targetZ, 2, color)
        self:processObstacleDetection(obstacleInfo, obstacle, i)

        local textX, textY = self:getScreenCoords(targetX, targetY, targetZ)
        if textX and textY then
            renderFontDrawText(font, tostring(i), textX, textY, color)
        end
    end

    return obstacleInfo, allLinesOccupied
end

function DrivingAssistant:getMultiplier(index)
    local speedVector = { getCarSpeedVector(getCarCharIsUsing(PLAYER_PED), true) }
    local speed = math.sqrt(speedVector[1]^2 + speedVector[2]^2 + speedVector[3]^2)
    local speedFactor = 1 + speed / 10
    return index == 0 and 0.5 * speedFactor or (self.userInputMultiplier - 0.2 * math.abs(index)) * speedFactor
end

function DrivingAssistant:getTargetCoords(offsetX, offsetY, radPitch, multiplier, sinRadian, cosRadian)
    return offsetX + multiplier * sinRadian,
           offsetY + multiplier * cosRadian,
           offsetX + multiplier * math.sin(radPitch)
end

function DrivingAssistant:processObstacleDetection(obstacleInfo, obstacle, index)
    if obstacle then
        addOneOffSound(0.0, 0.0, 0.0, 1139)
        printStringNow('DETECTED', 100)
        obstacleInfo.detected.center = obstacleInfo.detected.center or index == 0
        obstacleInfo.detected.right = obstacleInfo.detected.right or (index > 0)
        obstacleInfo.detected.left = obstacleInfo.detected.left or (index < 0)
        obstacleInfo.detected.front = obstacleInfo.detected.front or (index ~= 0)
        obstacleInfo.specific[index] = true
    end
end

function DrivingAssistant:handleObstacles(obstacleInfo, allLinesOccupied)
    if obstacleInfo.detected.center then
        self:simulateKeyPress(VK_S, 1000)
    end

    if allLinesOccupied then
        if self.lastTurnDirection == 'right' then
            self:simulateKeyPress(VK_D, 250)
        elseif self.lastTurnDirection == 'left' then
            self:simulateKeyPress(VK_A, 250)
        else
            print('Неизвестно')
        end
    elseif obstacleInfo.detected.front then
        local leftCount, rightCount = 0, 0
        for i, detected in pairs(obstacleInfo.specific) do
            if i < 0 then
                leftCount = leftCount + 1
            elseif i > 0 then
                rightCount = rightCount + 1
            end
        end

        if leftCount > rightCount then
            self.lastTurnDirection = 'right'
            self:simulateKeyPress(VK_D, 250)
        elseif rightCount > leftCount then
            self.lastTurnDirection = 'left'
            self:simulateKeyPress(VK_A, 250)
        end
    end
end

function DrivingAssistant:simulateKeyPress(key, duration)
    lua_thread.create(function()
        setVirtualKeyDown(key, true)
        wait(duration)
        setVirtualKeyDown(key, false)
    end)
end

function DrivingAssistant:getPlayerCoordsAndHeading()
    return { coords = getCharCoordinates(PLAYER_PED), heading = getCharHeading(PLAYER_PED) }
end

function DrivingAssistant:getOffsetCoords(playerCoords, radOffset)
    if isCharInAnyCar(PLAYER_PED) then
        return playerCoords[1] + 0.6 * math.sin(radOffset),
               playerCoords[2] + 0.6 * math.cos(radOffset)
    else
        return playerCoords[1], playerCoords[2]
    end
end

function DrivingAssistant:isObstacleInFront(x, y, targetX, targetY, targetZ)
    return processLineOfSight(x, y, 0.0, targetX, targetY, targetZ, true, true, true, true, true, false, false, false)
end

function DrivingAssistant:getScreenCoords(x, y, z)
    local success, screenX, screenY = convert3DCoordsToScreenEx(x, y, z)
    if success then
        return screenX, screenY
    end
end

function DrivingAssistant:renderLine3D(x1, y1, z1, x2, y2, z2, width, color)
    local success1, screenX1, screenY1 = convert3DCoordsToScreenEx(x1, y1, z1)
    local success2, screenX2, screenY2 = convert3DCoordsToScreenEx(x2, y2, z2)

    if success1 and success2 and isPointOnScreen(x2, y2, z2, 1.0) then
        renderDrawLine(screenX1, screenY1, screenX2, screenY2, width, color)
    end
end

function main()
    local assistant = DrivingAssistant:new()
    local F5L = false

    while not isSampAvailable() do wait(0) end

    sampRegisterChatCommand('helpmedrive', function()
        assistant:toggleDriving()
    end)

    sampRegisterChatCommand('setmultiplier', function(param)
        local value = tonumber(param)
        if value then
            assistant.userInputMultiplier = value
            sampAddChatMessage('Множитель дистанции установлен на: ' .. value, -1)
        else
            sampAddChatMessage('Ошибка: Неверное значение множителя.', -1)
        end
    end)

    while true do
        wait(0)
        local F5T = isKeyDown(VK_F5)

        if F5T and not F5L then
            assistant:toggleDriving()
        end

        F5L = F5T

        if assistant.drivingEnabled then
            local status, err = pcall(function() assistant:processDriving() end)
            if not status then
                print('ERROR: ' .. err)
            end
        end
    end
end
```