Новое окно imgui

bTosda_21

Участник
Автор темы
72
3
Почему не открывается новое окно?

require "lib.moonloader"
local imgui = require "imgui"
local sampev = require "lib.samp.events"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8

local main_window_state = imgui.ImBool(false)
local dual_window_state = imgui.ImBool(false)
local text_login = imgui.ImBuffer(265)
local text_pass = imgui.ImBuffer(265)
imgui.ToggleButton = require('imgui_addons').ToggleButton

function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
_, playerid = sampGetPlayerIdByCharHandle(PLAYER_PED)
imgui.Process = false
sampRegisterChatCommand("rieltor", cmd_rieltor)
ip, port = sampGetCurrentServerAddress()
while true do
wait(0)
if main_window_state.v == false then
imgui.Process = false
end
if dual_window_state.v == false then
imgui.Process = false
end
end
end


function cmd_rieltor(arg)
main_window_state.v = not main_window_state.v
dual_window_state.v = not dual_window_state.v
imgui.Process = main_window_state.v
imgui.Process = dual_window_state.v
end

local imBool = imgui.ImBool(false)
local imBool2 = imgui.ImBool(false)

function imgui.OnDrawFrame()
local iScreenWidth, iScreenHeight = getScreenResolution()
imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth / 2, iScreenHeight / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(400, 200), imgui.Cond.FirstUseEver)
imgui.Begin(u8"Настройки", main_window_state)
imgui.Text(u8"Логин")
imgui.InputText("",text_login)
imgui.Text(u8"Пароль")
imgui.InputText("",text_pass)
if imgui.Button(u8"Закрыть") then
imgui.Begin("DIALOG", dual_window_state)
imgui.Text(u8"Заработай плз")
imgui.End()
end
if imgui.Button(u8"Войти") then
sampAddChatMessage("ок", 0xFFFFFF)
end
if imgui.ToggleButton("Button", imBool) then
sampAddChatMessage("You change status, new status: " .. tostring(imBool.v), -1)
end
imgui.Button('Go')
imgui.Text(u8("Выход в AFK при LOW HP"))
imgui.SameLine(300)
if imgui.ToggleButton("Test2##2", imBool2) then
sampAddChatMessage("Выход в AFK включен", -1)
end
imgui.End()
end