Помогите с imgui.BeginChild

Azenizzka

Участник
Автор темы
27
23
Версия MoonLoader
.026-beta
Как исправить то, что следующая функуия после активации скрипта (togglebutton) выполняется снизу? Хочу сделать так, что бы все было справа, относительно менюшки слева. Извинябсь за корявый код :(
1669034771689.png
1669034779510.png


script_name("Nestero Helper")
script_author("Azenizzka")
-----
require "lib.moonloader"
local vkeys = require "vkeys"
local rkeys = require "rkeys"
local inicfg = require "inicfg"
-----
local imadd = require 'imgui_addons'
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8
imgui.HotKey = require("imgui_addons").HotKey
-----
local directIni = "NesteroHelper.ini"
local mainIni = inicfg.load({
settings = {
key = "[18,82]",
autoreconnect = false,
minrecon = 10,
maxrecon = 50
}
}, 'NesteroHelper')
if not doesFileExist('NesteroHelper.ini') then
inicfg.save(mainIni, 'NesteroHelper.ini')
end
-----
local main_window_state = imgui.ImBool(true)
local autoreconnect = imgui.ImBool(mainIni.settings.autoreconnect)
local minrecon = imgui.ImInt(mainIni.settings.minrecon)
local maxrecon = imgui.ImInt(mainIni.settings.maxrecon)
local sw, sh = getScreenResolution()
local select = 1
-----
local tag = "[Nestero Helper] "
local tagcolor = 0x20f271
local textcolor = "{DCDCDC}"
local warncolor = "{9c9c9c}"
-----
local ActiveMenu = {
v = decodeJson(mainIni.settings.key)
}
-----
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand("neshelp", neshelp_cmd)
sampRegisterChatCommand("reconnect", reconnect_cmd)
sampAddChatMessage(tag .. textcolor .. "Скрипт успешно загружен!", tagcolor)
sampAddChatMessage(tag .. textcolor .. "Автор скрипта: Azenizzka", tagcolor)
theme()
imgui.Process = true
while true do
wait(0)
if not sampIsChatInputActive() then
bindMenu = rkeys.registerHotKey(ActiveMenu.v, true, neshelp_cmd)
end
if isKeyJustPressed(VK_ESCAPE) then
main_window_state.v = false
imgui.Process = false
end
if autoreconnect.v == true then
autoreconnect_func()
end
if main_window_state.v == false then
imgui.Process = false
end
end
end
-----
function theme()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
style.WindowPadding = imgui.ImVec2(8, 8)
style.WindowRounding = 5
style.ChildWindowRounding = 5
style.FramePadding = imgui.ImVec2(5, 3)
style.FrameRounding = 3.0
style.ItemSpacing = imgui.ImVec2(5, 4)
style.ItemInnerSpacing = imgui.ImVec2(4, 4)
style.IndentSpacing = 21
style.ScrollbarSize = 10.0
style.ScrollbarRounding = 13
style.GrabMinSize = 8
style.GrabRounding = 1
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
colors[clr.Text] = ImVec4(0.90, 0.90, 0.90, 1.00)
colors[clr.TextDisabled] = ImVec4(0.60, 0.60, 0.60, 1.00)
colors[clr.WindowBg] = ImVec4(0.08, 0.08, 0.08, 1)
colors[clr.ChildWindowBg] = ImVec4(0.10, 0.10, 0.10, 1.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 1.00)
colors[clr.Border] = ImVec4(0.70, 0.70, 0.70, 0.40)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.15, 0.15, 0.15, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.19, 0.19, 0.19, 0.71)
colors[clr.FrameBgActive] = ImVec4(0.34, 0.34, 0.34, 0.79)
colors[clr.TitleBg] = ImVec4(0.00, 0.69, 0.33, 0.80)
colors[clr.TitleBgActive] = ImVec4(0.00, 0.74, 0.36, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.69, 0.33, 0.50)
colors[clr.MenuBarBg] = ImVec4(0.00, 0.80, 0.38, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.16, 0.16, 0.16, 1.00)
colors[clr.ScrollbarGrab] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 0.82, 0.39, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 1.00, 0.48, 1.00)
colors[clr.ComboBg] = ImVec4(0.20, 0.20, 0.20, 0.99)
colors[clr.CheckMark] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.SliderGrab] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.00, 0.77, 0.37, 1.00)
colors[clr.Button] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.ButtonHovered] = ImVec4(0.00, 0.82, 0.39, 1.00)
colors[clr.ButtonActive] = ImVec4(0.00, 0.87, 0.42, 1.00)
colors[clr.Header] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.HeaderHovered] = ImVec4(0.00, 0.76, 0.37, 0.57)
colors[clr.HeaderActive] = ImVec4(0.00, 0.88, 0.42, 0.89)
colors[clr.Separator] = ImVec4(1.00, 1.00, 1.00, 0.40)
colors[clr.SeparatorHovered] = ImVec4(1.00, 1.00, 1.00, 0.60)
colors[clr.SeparatorActive] = ImVec4(1.00, 1.00, 1.00, 0.80)
colors[clr.ResizeGrip] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.ResizeGripHovered] = ImVec4(0.00, 0.76, 0.37, 1.00)
colors[clr.ResizeGripActive] = ImVec4(0.00, 0.86, 0.41, 1.00)
colors[clr.CloseButton] = ImVec4(0.00, 0.90, 0.50, 1.00)
colors[clr.CloseButtonHovered] = ImVec4(0.00, 0.88, 0.42, 1.00)
colors[clr.CloseButtonActive] = ImVec4(0.00, 1.00, 0.48, 1.00)
colors[clr.PlotLines] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(0.00, 0.74, 0.36, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.PlotHistogramHovered] = ImVec4(0.00, 0.80, 0.38, 1.00)
colors[clr.TextSelectedBg] = ImVec4(0.00, 0.69, 0.33, 0.72)
colors[clr.ModalWindowDarkening] = ImVec4(0.17, 0.17, 0.17, 0.48)
end
-----
function imgui.OnDrawFrame()
-----
imgui.SetNextWindowSize(imgui.ImVec2(1000, 600), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/4), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
-----
imgui.Begin("Nestero Helper", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
-----
imgui.BeginGroup()
imgui.BeginChild('', imgui.ImVec2(150, 565), true)
if imgui.Button(u8'Настройки скрипта', imgui.ImVec2(130, 25)) then
select = 1
end
if imgui.Button(u8'Настройки', imgui.ImVec2(130, 25)) then
select = 2
end
imgui.EndChild()
imgui.EndGroup()
-----
imgui.SameLine()
imgui.BeginGroup()
if select == 1 then
imgui.SameLine()
if imgui.HotKey('##1', ActiveMenu, _, 50) then
rkeys.changeHotKey(bindMenu, ActiveMenu.v)
sampAddChatMessage(tag .. textcolor .. "Вы успешно изменили клавишу активации на: " .. warncolor .. table.concat(rkeys.getKeysName(ActiveMenu.v), " + "), tagcolor)
mainIni.settings.key = encodeJson(ActiveMenu.v)
inicfg.save(mainIni, directIni)
end
imgui.SameLine()
imgui.Text(u8'Активация скрипта')
imadd.ToggleButton("##active", autoreconnect)
imgui.SameLine()
imgui.Text(u8'Автореконнект')
mainIni.settings.autoreconnect = autoreconnect.v
inicfg.save(mainIni, directIni)
elseif select == 2 then
imgui.PushItemWidth(100)
imgui.InputInt(u8"Минимальная задержка", minrecon)
imgui.PopItemWidth()
mainIni.settings.minrecon = minrecon.v
inicfg.save(mainIni, directIni)
imgui.PushItemWidth(100)
imgui.InputInt(u8"Максимальная задержка", maxrecon)
imgui.PopItemWidth()
mainIni.settings.maxrecon = maxrecon.v
inicfg.save(mainIni, directIni)
end
imgui.EndGroup()
imgui.End()
end
-----
function neshelp_cmd()
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
function autoreconnect_func()
onReceivePacket(id)
end
function onReceivePacket(id)
if id == 32 and autoreconnect.v then
lua_thread.create(function()
local ip, port = sampGetCurrentServerAddress()
math.randomseed(os.clock())
local a = math.random(minrecon.v, maxrecon.v)
sampAddChatMessage(tag .. textcolor .. 'Задержка: '.. warncolor.. a .. textcolor ..' сек.', tagcolor)
wait(a * 1000)
if not id == 32 then
sampConnectToServer(ip, port)
else
sampAddChatMessage(tag .. textcolor .. "Отмена автореконнекта, вы уже перезашли.", tagcolor)
end
end)
end
end
function reconnect_cmd(arg)
lua_thread.create(function()
local ip, port = sampGetCurrentServerAddress()
sampAddChatMessage(tag .. textcolor .. 'Задержка: '.. warncolor.. arg .. textcolor ..' сек.', tagcolor)
wait(arg * 1000)
sampConnectToServer(ip, port)
end)
end


Lua:
script_name("Nestero Helper")
script_author("Azenizzka")

-----

require "lib.moonloader"
local vkeys = require "vkeys"
local rkeys = require "rkeys"
local inicfg = require "inicfg"

-----
local imadd = require 'imgui_addons'
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8
imgui.HotKey = require("imgui_addons").HotKey

-----

local directIni = "NesteroHelper.ini"
local mainIni = inicfg.load({
    settings = {
        key = "[18,82]",
        autoreconnect = false,
        minrecon = 10,
        maxrecon = 50
    }
}, 'NesteroHelper')
if not doesFileExist('NesteroHelper.ini') then
    inicfg.save(mainIni, 'NesteroHelper.ini')
end

-----

local main_window_state = imgui.ImBool(true)
local autoreconnect = imgui.ImBool(mainIni.settings.autoreconnect)
local minrecon = imgui.ImInt(mainIni.settings.minrecon)
local maxrecon = imgui.ImInt(mainIni.settings.maxrecon)
local sw, sh = getScreenResolution()
local select = 1

-----

local tag = "[Nestero Helper] "
local tagcolor = 0x20f271
local textcolor = "{DCDCDC}"
local warncolor = "{9c9c9c}"

-----

local ActiveMenu = {
    v = decodeJson(mainIni.settings.key)
}

-----

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(0) end

    sampRegisterChatCommand("neshelp", neshelp_cmd)
    sampRegisterChatCommand("reconnect", reconnect_cmd)

    sampAddChatMessage(tag .. textcolor .. "Скрипт успешно загружен!", tagcolor)
    sampAddChatMessage(tag .. textcolor .. "Автор скрипта: Azenizzka", tagcolor)

    theme()

    imgui.Process = true

    while true do
        wait(0)

        if not sampIsChatInputActive() then
            bindMenu = rkeys.registerHotKey(ActiveMenu.v, true, neshelp_cmd)
        end

        if isKeyJustPressed(VK_ESCAPE) then
            main_window_state.v = false
            imgui.Process = false
        end

        if autoreconnect.v == true then
            autoreconnect_func()
        end

        if main_window_state.v == false then
            imgui.Process = false
        end

    end

end

-----

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 5
    style.ChildWindowRounding = 5
    style.FramePadding = imgui.ImVec2(5, 3)
    style.FrameRounding = 3.0
    style.ItemSpacing = imgui.ImVec2(5, 4)
    style.ItemInnerSpacing = imgui.ImVec2(4, 4)
    style.IndentSpacing = 21
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 13
    style.GrabMinSize = 8
    style.GrabRounding = 1
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
    colors[clr.Text]                   = ImVec4(0.90, 0.90, 0.90, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.60, 0.60, 0.60, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.08, 0.08, 0.08, 1)
    colors[clr.ChildWindowBg]          = ImVec4(0.10, 0.10, 0.10, 1.00)
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 1.00)
    colors[clr.Border]                 = ImVec4(0.70, 0.70, 0.70, 0.40)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]                = ImVec4(0.15, 0.15, 0.15, 1.00)
    colors[clr.FrameBgHovered]         = ImVec4(0.19, 0.19, 0.19, 0.71)
    colors[clr.FrameBgActive]          = ImVec4(0.34, 0.34, 0.34, 0.79)
    colors[clr.TitleBg]                = ImVec4(0.00, 0.69, 0.33, 0.80)
    colors[clr.TitleBgActive]          = ImVec4(0.00, 0.74, 0.36, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.69, 0.33, 0.50)
    colors[clr.MenuBarBg]              = ImVec4(0.00, 0.80, 0.38, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.16, 0.16, 0.16, 1.00)
    colors[clr.ScrollbarGrab]          = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.00, 0.82, 0.39, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.00, 1.00, 0.48, 1.00)
    colors[clr.ComboBg]                = ImVec4(0.20, 0.20, 0.20, 0.99)
    colors[clr.CheckMark]              = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.00, 0.77, 0.37, 1.00)
    colors[clr.Button]                 = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.ButtonHovered]          = ImVec4(0.00, 0.82, 0.39, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.00, 0.87, 0.42, 1.00)
    colors[clr.Header]                 = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.HeaderHovered]          = ImVec4(0.00, 0.76, 0.37, 0.57)
    colors[clr.HeaderActive]           = ImVec4(0.00, 0.88, 0.42, 0.89)
    colors[clr.Separator]              = ImVec4(1.00, 1.00, 1.00, 0.40)
    colors[clr.SeparatorHovered]       = ImVec4(1.00, 1.00, 1.00, 0.60)
    colors[clr.SeparatorActive]        = ImVec4(1.00, 1.00, 1.00, 0.80)
    colors[clr.ResizeGrip]             = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.ResizeGripHovered]      = ImVec4(0.00, 0.76, 0.37, 1.00)
    colors[clr.ResizeGripActive]       = ImVec4(0.00, 0.86, 0.41, 1.00)
    colors[clr.CloseButton]            = ImVec4(0.00, 0.90, 0.50, 1.00)
    colors[clr.CloseButtonHovered]     = ImVec4(0.00, 0.88, 0.42, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.00, 1.00, 0.48, 1.00)
    colors[clr.PlotLines]              = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(0.00, 0.74, 0.36, 1.00)
    colors[clr.PlotHistogram]          = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(0.00, 0.80, 0.38, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.00, 0.69, 0.33, 0.72)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.17, 0.17, 0.17, 0.48)
end

-----

function imgui.OnDrawFrame()

-----

    imgui.SetNextWindowSize(imgui.ImVec2(1000, 600), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2((sw/4), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

-----
    imgui.Begin("Nestero Helper", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)

-----

    imgui.BeginGroup()
    imgui.BeginChild('', imgui.ImVec2(150, 565), true)

    if imgui.Button(u8'Настройки скрипта', imgui.ImVec2(130, 25)) then
        select = 1
    end

    if imgui.Button(u8'Настройки', imgui.ImVec2(130, 25)) then
        select = 2
    end

    imgui.EndChild()
    imgui.EndGroup()

-----

    imgui.SameLine()
    imgui.BeginGroup()

    if select == 1 then
        imgui.SameLine()
        if imgui.HotKey('##1', ActiveMenu, _, 50) then
            rkeys.changeHotKey(bindMenu, ActiveMenu.v)
            sampAddChatMessage(tag .. textcolor .. "Вы успешно изменили клавишу активации на: " .. warncolor .. table.concat(rkeys.getKeysName(ActiveMenu.v), " + "), tagcolor)
            mainIni.settings.key = encodeJson(ActiveMenu.v)
            inicfg.save(mainIni, directIni)
        end
        imgui.SameLine()
        imgui.Text(u8'Активация скрипта')
        imadd.ToggleButton("##active", autoreconnect)
        imgui.SameLine()
        imgui.Text(u8'Автореконнект')
        mainIni.settings.autoreconnect = autoreconnect.v
        inicfg.save(mainIni, directIni)

    elseif select == 2 then
        imgui.PushItemWidth(100)
        imgui.InputInt(u8"Минимальная задержка", minrecon)
        imgui.PopItemWidth()

        mainIni.settings.minrecon = minrecon.v
        inicfg.save(mainIni, directIni)

        imgui.PushItemWidth(100)
        imgui.InputInt(u8"Максимальная задержка", maxrecon)
        imgui.PopItemWidth()

        mainIni.settings.maxrecon = maxrecon.v
        inicfg.save(mainIni, directIni)
    end

    imgui.EndGroup()
    imgui.End()
end

-----

function neshelp_cmd()
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function autoreconnect_func()
    onReceivePacket(id)
end

function onReceivePacket(id)
    if id == 32 and autoreconnect.v then
        lua_thread.create(function()
            local ip, port = sampGetCurrentServerAddress()
            math.randomseed(os.clock())
            local a = math.random(minrecon.v, maxrecon.v)
            sampAddChatMessage(tag .. textcolor .. 'Задержка: '.. warncolor.. a .. textcolor ..' сек.', tagcolor)
            wait(a * 1000)
            if not id == 32 then
                 sampConnectToServer(ip, port)
            else
                sampAddChatMessage(tag .. textcolor .. "Отмена автореконнекта, вы уже перезашли.", tagcolor)
            end
        end)
    end
end

function reconnect_cmd(arg)
    lua_thread.create(function()
        local ip, port = sampGetCurrentServerAddress()
        sampAddChatMessage(tag .. textcolor .. 'Задержка: '.. warncolor.. arg .. textcolor ..' сек.', tagcolor)
        wait(arg * 1000)
        sampConnectToServer(ip, port)
    end)
end
 
  • Злость
Реакции: qdIbp

why ega

РП игрок
Модератор
2,537
2,219
Как исправить то, что следующая функуия после активации скрипта (togglebutton) выполняется снизу? Хочу сделать так, что бы все было справа, относительно менюшки слева. Извинябсь за корявый код :(Посмотреть вложение 178681Посмотреть вложение 178682

script_name("Nestero Helper")
script_author("Azenizzka")
-----
require "lib.moonloader"
local vkeys = require "vkeys"
local rkeys = require "rkeys"
local inicfg = require "inicfg"
-----
local imadd = require 'imgui_addons'
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8
imgui.HotKey = require("imgui_addons").HotKey
-----
local directIni = "NesteroHelper.ini"
local mainIni = inicfg.load({
settings = {
key = "[18,82]",
autoreconnect = false,
minrecon = 10,
maxrecon = 50
}
}, 'NesteroHelper')
if not doesFileExist('NesteroHelper.ini') then
inicfg.save(mainIni, 'NesteroHelper.ini')
end
-----
local main_window_state = imgui.ImBool(true)
local autoreconnect = imgui.ImBool(mainIni.settings.autoreconnect)
local minrecon = imgui.ImInt(mainIni.settings.minrecon)
local maxrecon = imgui.ImInt(mainIni.settings.maxrecon)
local sw, sh = getScreenResolution()
local select = 1
-----
local tag = "[Nestero Helper] "
local tagcolor = 0x20f271
local textcolor = "{DCDCDC}"
local warncolor = "{9c9c9c}"
-----
local ActiveMenu = {
v = decodeJson(mainIni.settings.key)
}
-----
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand("neshelp", neshelp_cmd)
sampRegisterChatCommand("reconnect", reconnect_cmd)
sampAddChatMessage(tag .. textcolor .. "Скрипт успешно загружен!", tagcolor)
sampAddChatMessage(tag .. textcolor .. "Автор скрипта: Azenizzka", tagcolor)
theme()
imgui.Process = true
while true do
wait(0)
if not sampIsChatInputActive() then
bindMenu = rkeys.registerHotKey(ActiveMenu.v, true, neshelp_cmd)
end
if isKeyJustPressed(VK_ESCAPE) then
main_window_state.v = false
imgui.Process = false
end
if autoreconnect.v == true then
autoreconnect_func()
end
if main_window_state.v == false then
imgui.Process = false
end
end
end
-----
function theme()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
style.WindowPadding = imgui.ImVec2(8, 8)
style.WindowRounding = 5
style.ChildWindowRounding = 5
style.FramePadding = imgui.ImVec2(5, 3)
style.FrameRounding = 3.0
style.ItemSpacing = imgui.ImVec2(5, 4)
style.ItemInnerSpacing = imgui.ImVec2(4, 4)
style.IndentSpacing = 21
style.ScrollbarSize = 10.0
style.ScrollbarRounding = 13
style.GrabMinSize = 8
style.GrabRounding = 1
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
colors[clr.Text] = ImVec4(0.90, 0.90, 0.90, 1.00)
colors[clr.TextDisabled] = ImVec4(0.60, 0.60, 0.60, 1.00)
colors[clr.WindowBg] = ImVec4(0.08, 0.08, 0.08, 1)
colors[clr.ChildWindowBg] = ImVec4(0.10, 0.10, 0.10, 1.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 1.00)
colors[clr.Border] = ImVec4(0.70, 0.70, 0.70, 0.40)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.15, 0.15, 0.15, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.19, 0.19, 0.19, 0.71)
colors[clr.FrameBgActive] = ImVec4(0.34, 0.34, 0.34, 0.79)
colors[clr.TitleBg] = ImVec4(0.00, 0.69, 0.33, 0.80)
colors[clr.TitleBgActive] = ImVec4(0.00, 0.74, 0.36, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.69, 0.33, 0.50)
colors[clr.MenuBarBg] = ImVec4(0.00, 0.80, 0.38, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.16, 0.16, 0.16, 1.00)
colors[clr.ScrollbarGrab] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 0.82, 0.39, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 1.00, 0.48, 1.00)
colors[clr.ComboBg] = ImVec4(0.20, 0.20, 0.20, 0.99)
colors[clr.CheckMark] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.SliderGrab] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.00, 0.77, 0.37, 1.00)
colors[clr.Button] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.ButtonHovered] = ImVec4(0.00, 0.82, 0.39, 1.00)
colors[clr.ButtonActive] = ImVec4(0.00, 0.87, 0.42, 1.00)
colors[clr.Header] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.HeaderHovered] = ImVec4(0.00, 0.76, 0.37, 0.57)
colors[clr.HeaderActive] = ImVec4(0.00, 0.88, 0.42, 0.89)
colors[clr.Separator] = ImVec4(1.00, 1.00, 1.00, 0.40)
colors[clr.SeparatorHovered] = ImVec4(1.00, 1.00, 1.00, 0.60)
colors[clr.SeparatorActive] = ImVec4(1.00, 1.00, 1.00, 0.80)
colors[clr.ResizeGrip] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.ResizeGripHovered] = ImVec4(0.00, 0.76, 0.37, 1.00)
colors[clr.ResizeGripActive] = ImVec4(0.00, 0.86, 0.41, 1.00)
colors[clr.CloseButton] = ImVec4(0.00, 0.90, 0.50, 1.00)
colors[clr.CloseButtonHovered] = ImVec4(0.00, 0.88, 0.42, 1.00)
colors[clr.CloseButtonActive] = ImVec4(0.00, 1.00, 0.48, 1.00)
colors[clr.PlotLines] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(0.00, 0.74, 0.36, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.00, 0.69, 0.33, 1.00)
colors[clr.PlotHistogramHovered] = ImVec4(0.00, 0.80, 0.38, 1.00)
colors[clr.TextSelectedBg] = ImVec4(0.00, 0.69, 0.33, 0.72)
colors[clr.ModalWindowDarkening] = ImVec4(0.17, 0.17, 0.17, 0.48)
end
-----
function imgui.OnDrawFrame()
-----
imgui.SetNextWindowSize(imgui.ImVec2(1000, 600), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw/4), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
-----
imgui.Begin("Nestero Helper", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
-----
imgui.BeginGroup()
imgui.BeginChild('', imgui.ImVec2(150, 565), true)
if imgui.Button(u8'Настройки скрипта', imgui.ImVec2(130, 25)) then
select = 1
end
if imgui.Button(u8'Настройки', imgui.ImVec2(130, 25)) then
select = 2
end
imgui.EndChild()
imgui.EndGroup()
-----
imgui.SameLine()
imgui.BeginGroup()
if select == 1 then
imgui.SameLine()
if imgui.HotKey('##1', ActiveMenu, _, 50) then
rkeys.changeHotKey(bindMenu, ActiveMenu.v)
sampAddChatMessage(tag .. textcolor .. "Вы успешно изменили клавишу активации на: " .. warncolor .. table.concat(rkeys.getKeysName(ActiveMenu.v), " + "), tagcolor)
mainIni.settings.key = encodeJson(ActiveMenu.v)
inicfg.save(mainIni, directIni)
end
imgui.SameLine()
imgui.Text(u8'Активация скрипта')
imadd.ToggleButton("##active", autoreconnect)
imgui.SameLine()
imgui.Text(u8'Автореконнект')
mainIni.settings.autoreconnect = autoreconnect.v
inicfg.save(mainIni, directIni)
elseif select == 2 then
imgui.PushItemWidth(100)
imgui.InputInt(u8"Минимальная задержка", minrecon)
imgui.PopItemWidth()
mainIni.settings.minrecon = minrecon.v
inicfg.save(mainIni, directIni)
imgui.PushItemWidth(100)
imgui.InputInt(u8"Максимальная задержка", maxrecon)
imgui.PopItemWidth()
mainIni.settings.maxrecon = maxrecon.v
inicfg.save(mainIni, directIni)
end
imgui.EndGroup()
imgui.End()
end
-----
function neshelp_cmd()
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
function autoreconnect_func()
onReceivePacket(id)
end
function onReceivePacket(id)
if id == 32 and autoreconnect.v then
lua_thread.create(function()
local ip, port = sampGetCurrentServerAddress()
math.randomseed(os.clock())
local a = math.random(minrecon.v, maxrecon.v)
sampAddChatMessage(tag .. textcolor .. 'Задержка: '.. warncolor.. a .. textcolor ..' сек.', tagcolor)
wait(a * 1000)
if not id == 32 then
sampConnectToServer(ip, port)
else
sampAddChatMessage(tag .. textcolor .. "Отмена автореконнекта, вы уже перезашли.", tagcolor)
end
end)
end
end
function reconnect_cmd(arg)
lua_thread.create(function()
local ip, port = sampGetCurrentServerAddress()
sampAddChatMessage(tag .. textcolor .. 'Задержка: '.. warncolor.. arg .. textcolor ..' сек.', tagcolor)
wait(arg * 1000)
sampConnectToServer(ip, port)
end)
end


Lua:
script_name("Nestero Helper")
script_author("Azenizzka")

-----

require "lib.moonloader"
local vkeys = require "vkeys"
local rkeys = require "rkeys"
local inicfg = require "inicfg"

-----
local imadd = require 'imgui_addons'
local imgui = require "imgui"
local encoding = require "encoding"
encoding.default = "CP1251"
u8 = encoding.UTF8
imgui.HotKey = require("imgui_addons").HotKey

-----

local directIni = "NesteroHelper.ini"
local mainIni = inicfg.load({
    settings = {
        key = "[18,82]",
        autoreconnect = false,
        minrecon = 10,
        maxrecon = 50
    }
}, 'NesteroHelper')
if not doesFileExist('NesteroHelper.ini') then
    inicfg.save(mainIni, 'NesteroHelper.ini')
end

-----

local main_window_state = imgui.ImBool(true)
local autoreconnect = imgui.ImBool(mainIni.settings.autoreconnect)
local minrecon = imgui.ImInt(mainIni.settings.minrecon)
local maxrecon = imgui.ImInt(mainIni.settings.maxrecon)
local sw, sh = getScreenResolution()
local select = 1

-----

local tag = "[Nestero Helper] "
local tagcolor = 0x20f271
local textcolor = "{DCDCDC}"
local warncolor = "{9c9c9c}"

-----

local ActiveMenu = {
    v = decodeJson(mainIni.settings.key)
}

-----

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(0) end

    sampRegisterChatCommand("neshelp", neshelp_cmd)
    sampRegisterChatCommand("reconnect", reconnect_cmd)

    sampAddChatMessage(tag .. textcolor .. "Скрипт успешно загружен!", tagcolor)
    sampAddChatMessage(tag .. textcolor .. "Автор скрипта: Azenizzka", tagcolor)

    theme()

    imgui.Process = true

    while true do
        wait(0)

        if not sampIsChatInputActive() then
            bindMenu = rkeys.registerHotKey(ActiveMenu.v, true, neshelp_cmd)
        end

        if isKeyJustPressed(VK_ESCAPE) then
            main_window_state.v = false
            imgui.Process = false
        end

        if autoreconnect.v == true then
            autoreconnect_func()
        end

        if main_window_state.v == false then
            imgui.Process = false
        end

    end

end

-----

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 5
    style.ChildWindowRounding = 5
    style.FramePadding = imgui.ImVec2(5, 3)
    style.FrameRounding = 3.0
    style.ItemSpacing = imgui.ImVec2(5, 4)
    style.ItemInnerSpacing = imgui.ImVec2(4, 4)
    style.IndentSpacing = 21
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 13
    style.GrabMinSize = 8
    style.GrabRounding = 1
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
    colors[clr.Text]                   = ImVec4(0.90, 0.90, 0.90, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.60, 0.60, 0.60, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.08, 0.08, 0.08, 1)
    colors[clr.ChildWindowBg]          = ImVec4(0.10, 0.10, 0.10, 1.00)
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 1.00)
    colors[clr.Border]                 = ImVec4(0.70, 0.70, 0.70, 0.40)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]                = ImVec4(0.15, 0.15, 0.15, 1.00)
    colors[clr.FrameBgHovered]         = ImVec4(0.19, 0.19, 0.19, 0.71)
    colors[clr.FrameBgActive]          = ImVec4(0.34, 0.34, 0.34, 0.79)
    colors[clr.TitleBg]                = ImVec4(0.00, 0.69, 0.33, 0.80)
    colors[clr.TitleBgActive]          = ImVec4(0.00, 0.74, 0.36, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.69, 0.33, 0.50)
    colors[clr.MenuBarBg]              = ImVec4(0.00, 0.80, 0.38, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.16, 0.16, 0.16, 1.00)
    colors[clr.ScrollbarGrab]          = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.00, 0.82, 0.39, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.00, 1.00, 0.48, 1.00)
    colors[clr.ComboBg]                = ImVec4(0.20, 0.20, 0.20, 0.99)
    colors[clr.CheckMark]              = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.00, 0.77, 0.37, 1.00)
    colors[clr.Button]                 = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.ButtonHovered]          = ImVec4(0.00, 0.82, 0.39, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.00, 0.87, 0.42, 1.00)
    colors[clr.Header]                 = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.HeaderHovered]          = ImVec4(0.00, 0.76, 0.37, 0.57)
    colors[clr.HeaderActive]           = ImVec4(0.00, 0.88, 0.42, 0.89)
    colors[clr.Separator]              = ImVec4(1.00, 1.00, 1.00, 0.40)
    colors[clr.SeparatorHovered]       = ImVec4(1.00, 1.00, 1.00, 0.60)
    colors[clr.SeparatorActive]        = ImVec4(1.00, 1.00, 1.00, 0.80)
    colors[clr.ResizeGrip]             = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.ResizeGripHovered]      = ImVec4(0.00, 0.76, 0.37, 1.00)
    colors[clr.ResizeGripActive]       = ImVec4(0.00, 0.86, 0.41, 1.00)
    colors[clr.CloseButton]            = ImVec4(0.00, 0.90, 0.50, 1.00)
    colors[clr.CloseButtonHovered]     = ImVec4(0.00, 0.88, 0.42, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.00, 1.00, 0.48, 1.00)
    colors[clr.PlotLines]              = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(0.00, 0.74, 0.36, 1.00)
    colors[clr.PlotHistogram]          = ImVec4(0.00, 0.69, 0.33, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(0.00, 0.80, 0.38, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.00, 0.69, 0.33, 0.72)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.17, 0.17, 0.17, 0.48)
end

-----

function imgui.OnDrawFrame()

-----

    imgui.SetNextWindowSize(imgui.ImVec2(1000, 600), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2((sw/4), sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

-----
    imgui.Begin("Nestero Helper", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)

-----

    imgui.BeginGroup()
    imgui.BeginChild('', imgui.ImVec2(150, 565), true)

    if imgui.Button(u8'Настройки скрипта', imgui.ImVec2(130, 25)) then
        select = 1
    end

    if imgui.Button(u8'Настройки', imgui.ImVec2(130, 25)) then
        select = 2
    end

    imgui.EndChild()
    imgui.EndGroup()

-----

    imgui.SameLine()
    imgui.BeginGroup()

    if select == 1 then
        imgui.SameLine()
        if imgui.HotKey('##1', ActiveMenu, _, 50) then
            rkeys.changeHotKey(bindMenu, ActiveMenu.v)
            sampAddChatMessage(tag .. textcolor .. "Вы успешно изменили клавишу активации на: " .. warncolor .. table.concat(rkeys.getKeysName(ActiveMenu.v), " + "), tagcolor)
            mainIni.settings.key = encodeJson(ActiveMenu.v)
            inicfg.save(mainIni, directIni)
        end
        imgui.SameLine()
        imgui.Text(u8'Активация скрипта')
        imadd.ToggleButton("##active", autoreconnect)
        imgui.SameLine()
        imgui.Text(u8'Автореконнект')
        mainIni.settings.autoreconnect = autoreconnect.v
        inicfg.save(mainIni, directIni)

    elseif select == 2 then
        imgui.PushItemWidth(100)
        imgui.InputInt(u8"Минимальная задержка", minrecon)
        imgui.PopItemWidth()

        mainIni.settings.minrecon = minrecon.v
        inicfg.save(mainIni, directIni)

        imgui.PushItemWidth(100)
        imgui.InputInt(u8"Максимальная задержка", maxrecon)
        imgui.PopItemWidth()

        mainIni.settings.maxrecon = maxrecon.v
        inicfg.save(mainIni, directIni)
    end

    imgui.EndGroup()
    imgui.End()
end

-----

function neshelp_cmd()
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function autoreconnect_func()
    onReceivePacket(id)
end

function onReceivePacket(id)
    if id == 32 and autoreconnect.v then
        lua_thread.create(function()
            local ip, port = sampGetCurrentServerAddress()
            math.randomseed(os.clock())
            local a = math.random(minrecon.v, maxrecon.v)
            sampAddChatMessage(tag .. textcolor .. 'Задержка: '.. warncolor.. a .. textcolor ..' сек.', tagcolor)
            wait(a * 1000)
            if not id == 32 then
                 sampConnectToServer(ip, port)
            else
                sampAddChatMessage(tag .. textcolor .. "Отмена автореконнекта, вы уже перезашли.", tagcolor)
            end
        end)
    end
end

function reconnect_cmd(arg)
    lua_thread.create(function()
        local ip, port = sampGetCurrentServerAddress()
        sampAddChatMessage(tag .. textcolor .. 'Задержка: '.. warncolor.. arg .. textcolor ..' сек.', tagcolor)
        wait(arg * 1000)
        sampConnectToServer(ip, port)
    end)
end
несовсем понял, но если тебе надо засунуть тогглебаттон на одну строку с чилдом, то просто перед тогглебаттоном напиши imgui.SameLine()
 

Azenizzka

Участник
Автор темы
27
23
несовсем понял, но если тебе надо засунуть тогглебаттон на одну строку с чилдом, то просто перед тогглебаттоном напиши imgui.SameLine()
не, надо, что бы тоггл баттон был прямо под

"кнопка активации скрипта"