Почему окно mimgui не закрывается? (код)

Po24

Участник
Автор темы
72
10
почему

mimgui:
local imgui = require('mimgui')
local ffi = require('ffi')
local encoding = require('encoding')
encoding.default = 'CP1251'
local u8 = encoding.UTF8

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
end)

local textcd = imgui.new.char[128]('500')
local textradius = imgui.new.char[128]('150')
local checkbox = imgui.new.bool(false)
local window = imgui.new.bool(true)
imgui.OnFrame(function() return true end,
function(this)

    local size, res = imgui.ImVec2(550, 350), imgui.ImVec2(getScreenResolution())

    imgui.SetNextWindowSize(size, imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2(res.x / 2, res.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    if (imgui.Begin('Troll Menu', window, imgui.WindowFlags.NoResize)) then
        if (imgui.Button('Explode random car in your radius', imgui.ImVec2(300, 50))) then

            local X, Y, Z = getCharCoordinates(PLAYER_PED)

            local _, veh = findAllRandomVehiclesInSphere(X, Y, Z, tonumber(ffi.string(textradius)), true, true)

            if _ then

                warpCharIntoCar(PLAYER_PED, veh)
                setCarHealth(veh, 1)
                warpCharFromCarToCoord(PLAYER_PED, X, Y, Z - 1)
                sampAddChatMessage('Exploded: '..veh, -1)
                    
            else

                sampAddChatMessage('Cant find a car in your radius', -1)

            end

        end

        imgui.Checkbox('Auto explode', checkbox)

        imgui.InputText('Enter cooldown in ms', textcd, 128)

        imgui.InputText('Enter radius', textradius, 128)

    end
        
    imgui.End()
end)

function main()

    while not isSampAvailable do wait(0) end

    wait(1000)

    while true do
        wait(tonumber(ffi.string(textcd)))
        if (checkbox[0]) then
            local X, Y, Z = getCharCoordinates(PLAYER_PED)

            local _, veh = findAllRandomVehiclesInSphere(X, Y, Z, tonumber(ffi.string(textradius)), true, true)

            if _ then

                warpCharIntoCar(PLAYER_PED, veh)
                setCarHealth(veh, 1)
                warpCharFromCarToCoord(PLAYER_PED, X, Y, Z - 1)
                sampAddChatMessage('Exploded: '..veh, -1)
                    
            else

                sampAddChatMessage('Cant find a car in your radius', -1)

            end
        end
    end

end
 

#Northn

Police Helper «Reborn» — уже ШЕСТЬ лет!
Всефорумный модератор
2,635
2,485
и в бегине условие не обязательно ставить, даже лучше вообще не ставить, потому что выглядит как хуйня
Документация требует этого
if imgui.Begin(...) then
...
end
imgui.End()
 
  • Клоун
Реакции: Fott

#Northn

Police Helper «Reborn» — уже ШЕСТЬ лет!
Всефорумный модератор
2,635
2,485
  • Клоун
  • Нравится
Реакции: Fott и XRLM