```lua
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local window = imgui.ImBool(false)
local checkboxValue = imgui.ImBool(false)
local checkboxBlipValue = imgui.ImBool(false)
local checkboxMarkerValue = imgui.ImBool(false)
local checkboxInCar = imgui.ImBool(false)
local enableInCarText = "Disabled"
local enableText = "Disabled"
local enableBlipText = "Disabled"
local enableMarkerText = "Disabled"
local pos = {x = imgui.ImBuffer(128), y = imgui.ImBuffer(128), z = imgui.ImBuffer(128)}
local stepDistance = imgui.ImInt(5)
local stepDelay = imgui.ImInt(1000)
local markerDistance = imgui.ImInt(100)
local visotaGovnovoz = imgui.ImInt(100)

function main()
    while not isSampAvailable() do 
        wait(200) 
    end
    imgui.Process = false
    window.v = false
    sampRegisterChatCommand("otp", toggleInterface)
    sampRegisterChatCommand("otpr", function()
        local posX, posY, posZ = tonumber(pos.x.v) or 0.0, tonumber(pos.y.v) or 0.0, tonumber(pos.z.v) or 0.0
        if posX and posY and posZ then
            if checkboxValue.v then
                teleportPlayerStepByStep(PLAYER_PED, posX, posY, posZ)
            else
                setCharCoordinates(PLAYER_PED, posX, posY, posZ)
            end
        else
            print("Debug")
        end
    end)
    while true do
        wait(0)
        imgui.Process = window.v
    end
end

function toggleInterface()
    window.v = not window.v
end

function SearchMarker(posX, posY, posZ, radius, isRace)
    local ret_posX = 0.0
    local ret_posY = 0.0
    local ret_posZ = 0.0
    local isFind = false

    for id = 0, 31 do
        local MarkerStruct = 0
        if isRace then 
            MarkerStruct = 0xC7F168 + id * 56
        else 
            MarkerStruct = 0xC7DD88 + id * 160 
        end
        local MarkerPosX = representIntAsFloat(readMemory(MarkerStruct + 0, 4, false))
        local MarkerPosY = representIntAsFloat(readMemory(MarkerStruct + 4, 4, false))
        local MarkerPosZ = representIntAsFloat(readMemory(MarkerStruct + 8, 4, false))

        if MarkerPosX ~= 0.0 or MarkerPosY ~= 0.0 or MarkerPosZ ~= 0.0 then
            if getDistanceBetweenCoords3d(MarkerPosX, MarkerPosY, MarkerPosZ, posX, posY, posZ) < radius then
                ret_posX = MarkerPosX
                ret_posY = MarkerPosY
                ret_posZ = MarkerPosZ
                isFind = true
                radius = getDistanceBetweenCoords3d(MarkerPosX, MarkerPosY, MarkerPosZ, posX, posY, posZ)
            end
        end
    end

    return isFind, ret_posX, ret_posY, ret_posZ
end

function getTargetBlipCoordinatesFixed()
    local bool, x, y, z = getTargetBlipCoordinates(); if not bool then return false end
    requestCollision(x, y); loadScene(x, y, z)
    local bool, x, y, z = getTargetBlipCoordinates()
    return bool, x, y, z
end

function samp_create_sync_data(sync_type, copy_from_player)
    local ffi = require 'ffi'
    local sampfuncs = require 'sampfuncs'
    -- from SAMP.Lua
    local raknet = require 'samp.raknet'
    require 'samp.synchronization'

    copy_from_player = copy_from_player or true
    local sync_traits = {
        player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
        vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
        passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
        aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
        trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
        unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
        bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
        spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
    }
    local sync_info = sync_traits[sync_type]
    local data_type = 'struct ' .. sync_info[1]
    local data = ffi.new(data_type, {})
    local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
    -- copy player's sync data to the allocated memory
    if copy_from_player then
        local copy_func = sync_info[3]
        if copy_func then
            local _, player_id
            if copy_from_player == true then
                _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            else
                player_id = tonumber(copy_from_player)
            end
            copy_func(player_id, raw_data_ptr)
        end
    end
    -- function to send packet
    local func_send = function()
        local bs = raknetNewBitStream()
        raknetBitStreamWriteInt8(bs, sync_info[2])
        raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
        raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
        raknetDeleteBitStream(bs)
    end
    -- metatable to access sync data and 'send' function
    local mt = {
        __index = function(t, index)
            return data[index]
        end,
        __newindex = function(t, index, value)
            data[index] = value
        end
    }
    return setmetatable({send = func_send}, mt)
end

function teleportPlayerStepByStep(playerPed, posX, posY, posZ)
    lua_thread.create(function()
        local playerX, playerY, playerZ = getCharCoordinates(playerPed)
        local groundZ = getGroundZFor3dCoord(posX, posY, posZ)
        local stepX = (posX - playerX) / stepDistance.v
        local stepY = (posY - playerY) / stepDistance.v
        local stepZ = (groundZ - playerZ) / stepDistance.v

        if math.abs(posX - playerX) > stepDistance.v or
        math.abs(posY - playerY) > stepDistance.v or
        math.abs(posZ - playerZ) > stepDistance.v then
            for i = 1, stepDistance.v do
                playerX = playerX + stepX
                playerY = playerY + stepY
                playerZ = playerZ + stepZ

                local data = samp_create_sync_data('player')
                data.moveSpeed.x = math.random(100, 1000)
                data.moveSpeed.y = math.random(100, 1000)
                data.moveSpeed.y = math.random(100, 1000)
                data.send()
                sampForceOnfootSync()
                setCharCoordinates(playerPed, playerX, playerY, playerZ)
                wait(stepDelay.v)
            end
        end
    end)
end

function imgui.OnDrawFrame()
    if window.v then
        imgui.SetNextWindowPos(imgui.ImVec2(350.0, 250.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(550, 450), imgui.Cond.FirstUseEver)
        imgui.Begin('OTP By Tectrex', window)

        if isCharInAnyCar(PLAYER_PED) then
            if checkboxInCar.v then
                local car = getCarCharIsUsing(PLAYER_PED)
                local posX, posY, posZ = tonumber(pos.x.v) or 0.0, tonumber(pos.y.v) or 0.0, tonumber(pos.z.v) or 0.0
                local carX, carY, carZ = getCarCoordinates(car)
                local h = getHeadingFromVector2d(posX - carX, posY - carY)
                setCarCoordinates(car, carX, carY, visotaGovnovoz.v)
                setCarForwardSpeed(car, 100)
                setCarHeading(car, h)
                setCharCanBeKnockedOffBike(PLAYER_PED, true)
            else
                freezeCarPosition(getCarCharIsUsing(PLAYER_PED), false)
                setCharCanBeKnockedOffBike(PLAYER_PED, false)
            end
            imgui.Text("Player incar")
        else
            imgui.Text("Player not incar")
        end                       

        if imgui.Checkbox("Enable Govnovoz", checkboxInCar) then
            enableInCarText = checkboxInCar.v and "Enabled" or "Disabled"
        end
        imgui.SetCursorPosX(100)
        imgui.SameLine()
        imgui.Text("Govnovoz: " .. enableInCarText) 

        if imgui.Checkbox("Enable Coord-Master", checkboxValue) then
            enableText = checkboxValue.v and "Enabled" or "Disabled"
        end
        imgui.SameLine()
        imgui.Text("Coord-Master: " .. enableText)      
        

        if imgui.Checkbox("Enable Blip Finder", checkboxBlipValue) then
            enableBlipText = checkboxBlipValue.v and "Enabled" or "Disabled"
        end
        imgui.SameLine()
        imgui.Text("Blip Finder: " .. enableBlipText)

        
        if checkboxBlipValue.v then
            local bool, blipX, blipY, blipZ = getTargetBlipCoordinatesFixed()
            if bool then
                pos.x.v, pos.y.v, pos.z.v = tostring(blipX), tostring(blipY), tostring(blipZ)
            else
                printStringNow("No blip found", 1000)
            end
        end

        if imgui.Checkbox("Enable Marker Finder", checkboxMarkerValue) then
            enableMarkerText = checkboxMarkerValue.v and "Enabled" or "Disabled"
        end
        imgui.SameLine()
        imgui.Text("Marker Finder: " .. enableMarkerText) 

        if checkboxMarkerValue.v then
            local posX, posY, posZ = getCharCoordinates(PLAYER_PED)
            local isFind, markerX, markerY, markerZ = SearchMarker(posX, posY, posZ, markerDistance.v, false)
            if isFind then
                pos.x.v, pos.y.v, pos.z.v = tostring(markerX), tostring(markerY), tostring(markerZ)
            else
                printStringNow("No marker found trying again.", 1000)
                local isFind2, markerX, markerY, markerZ = SearchMarker(posX, posY, posZ, markerDistance.v, true)
                if isFind2 then
                    pos.x.v, pos.y.v, pos.z.v = tostring(markerX), tostring(markerY), tostring(markerZ)
                end
            end
        end

        for _, v in pairs({"X", "Y", "Z"}) do
            if imgui.InputText(v, pos[v:lower()]) then
                print("Debug")
            end
        end

        if imgui.Button("Get PLAYER_PED Coordinates") then
            local x, y, z = getCharCoordinates(PLAYER_PED)
            pos.x.v, pos.y.v, pos.z.v = tostring(x), tostring(y), tostring(z)
        end

        if imgui.Button("Get Marker Coordinates") then
            local posX, posY, posZ = getCharCoordinates(PLAYER_PED)
            local isFind, markerX, markerY, markerZ = SearchMarker(posX, posY, posZ, markerDistance.v, false)
            if isFind then
                pos.x.v, pos.y.v, pos.z.v = tostring(markerX), tostring(markerY), tostring(markerZ)
            else
                printStringNow("No marker found trying again.", 1000)
                local isFind2, markerX, markerY, markerZ = SearchMarker(posX, posY, posZ, markerDistance.v, true)
                if isFind2 then
                    pos.x.v, pos.y.v, pos.z.v = tostring(markerX), tostring(markerY), tostring(markerZ)
                end
            end
        end
        
        if imgui.Button("Get Blip Coordinates") then
            local bool, blipX, blipY, blipZ = getTargetBlipCoordinatesFixed()
            if bool then
                pos.x.v, pos.y.v, pos.z.v = tostring(blipX), tostring(blipY), tostring(blipZ)
            else
                printStringNow("No blip found", 1000)
            end
        end

        imgui.Separator()

        if imgui.SliderInt("Visota", visotaGovnovoz, 1, 500) then
            printStringNow("Visota: " .. visotaGovnovoz.v, 1000)
        end

        imgui.SameLine()
        imgui.TextDisabled("(Высота говновоза)")

        imgui.Separator()

        if imgui.SliderInt("Step", stepDistance, 1, 500) then
            printStringNow("Step: " .. stepDistance.v, 1000)
        end

        imgui.SameLine()
        imgui.TextDisabled("(Кол-во шагов на тп)")

        imgui.Separator()
        
        if imgui.SliderInt("Step Delay (ms)", stepDelay, 0, 1000) then
            printStringNow("Step Delay: " .. stepDelay.v .. "ms", 1000)
        end

        imgui.SameLine()
        imgui.TextDisabled("(Задержка)")

        imgui.Separator()

        if imgui.SliderInt("MD", markerDistance, 1, 10000) then
            printStringNow("Distance: " .. markerDistance.v, 1000)
        end

        imgui.SameLine()
        imgui.TextDisabled("(Радиус поиска маркера)")

        imgui.Separator()

        if imgui.Button("Teleport") then
            local posX, posY, posZ = tonumber(pos.x.v) or 0.0, tonumber(pos.y.v) or 0.0, tonumber(pos.z.v) or 0.0
            if posX and posY and posZ then
                if checkboxValue.v then
                    teleportPlayerStepByStep(PLAYER_PED, posX, posY, posZ)
                else
                    setCharCoordinates(PLAYER_PED, posX, posY, posZ)
                end
            else
                print("Debug")
            end
        end   

        imgui.End()
    end
end
```
Преобразуй следующий код, чтобы он соответствовал уровню senior-разработчика: используй объектно-ориентированное программирование с инкапсуляцией, абстракцией и наследованием там, где это уместно, сделай архитектуру модульной, расширяемой и поддерживаемой, оптимизируй производительность и читаемость, улучшай именования переменных, функций и классов, устраняй дублирование кода, применяй подходящие паттерны проектирования для гибкости и масштабируемости, внедри обработку ошибок с информативными сообщениями и обеспечь логирование ключевых событий, добавь подробные комментарии и документацию к основным классам и методам, обеспечь финальный код простым для понимания, тестирования и поддержки.

SA-MP LUA MOONLOADER