MenuItem в mimgui

ReoGenT

Участник
Автор темы
90
6
Версия MoonLoader
.026-beta
Крашит скрипт:
Код:
[ML] (error) AdminMode: ...gram Files\GTA San Andreas\moonloader\AdminToolsTest.lua:155: attempt to call field 'MenuItem' (a nil value)
stack traceback:
    ...gram Files\GTA San Andreas\moonloader\AdminToolsTest.lua:155: in function '_draw'
    ...ram Files\GTA San Andreas\moonloader\lib\mimgui\init.lua:107: in function <...ram Files\GTA San Andreas\moonloader\lib\mimgui\init.lua:91>
[ML] (error) AdminMode: Script died due to an error. (1DE9164C)

Код из-за которого возможно крашит, можете пофиксить пожалуйста:

Lua:
local tag = 0
local newFrame = imgui.OnFrame(
    function() return remenu[0] end,
    function(player)
        if isKeyJustPressed(key.VK_RBUTTON) and not sampIsChatInputActive() and not sampIsDialogActive() then
            player.ShowCursor = not player.ShowCursor
        end
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 269, 394
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 8.3, resY / 1.45), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin(u8' ', remenu, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.MenuBar)
            imgui.BeginMenuBar()
                if imgui.MenuItem(u8'Основное') then
                    tag = 0
                end
                if imgui.MenuItem(u8'Наказание') then
                    tag = 1
                end
            imgui.EndMenuBar()
            if tag == 0 then
                if imgui.Button(u8'GOTOSP', imgui.ImVec2(80, 80)) then
                    sampSendChat('/gotosp '..spec_id)
                end
                imgui.SameLine(94)
                if imgui.Button(u8'GMTEST', imgui.ImVec2(80, 80)) then
                    sampSendChat('/gm '..spec_id)
                end
                imgui.SameLine(180)
                if imgui.Button(u8'STATS', imgui.ImVec2(80, 80)) then
                    sampSendChat('/getstats '..spec_id)
                end
                
                if imgui.Button(u8'GETIP', imgui.ImVec2(80, 80)) then
                    sampSendChat('/getip '..spec_id)
                end
                imgui.SameLine(94)
                if imgui.Button(u8'DM', imgui.ImVec2(80, 80)) then
                    sampSendChat('/prison '..spec_id..' 30 ДМ')
                end
                imgui.SameLine(180)
                if imgui.Button(u8'DB', imgui.ImVec2(80, 80)) then
                    sampSendChat('/prison '..spec_id..' 30 ДБ')
                end
                
                if imgui.Button(u8'SBIV', imgui.ImVec2(80, 80)) then
                    sampSendChat('/prison '..spec_id..' 10 Сбив (Чат)')
                end
                imgui.SameLine(94)
                if imgui.Button(u8'Человек из\nЧС проекта', imgui.ImVec2(80, 80)) then
                    sampSendChat('/iban '..spec_id..' ЧС сервера')
                end
                imgui.SameLine(180)
                if imgui.Button(u8'SLAP', imgui.ImVec2(80, 80)) then
                    sampSendChat('/slap '..spec_id..' ЧС сервера')
                end
                if imgui.Button(u8'REOFF', imgui.ImVec2(253, 25)) then
                    sampSendChat('/re')
                    remenu[0] = false
                end
                if imgui.Checkbox(u8'Включить меню управлением игроком', infmen) then
                    remen[0] = not remen[0]
                end
            end
            if tag == 1 then
                imgui.Text(u8'Причина кика:')
                imgui.InputText(u8' ', kick, ffi.sizeof(kick))
                if imgui.Button(u8'Кикнуть') then
                    sampSendChat(u8:decode('/kick '..spec_id..' '..ffi.string(kick)))
                end
                imgui.Text(u8'————————————————————————————————')
                imgui.Text(u8'Забанить за читы')
                if imgui.Button(u8'На 7 дней') then
                    sampSendChat('/ban '..spec_id..' 7 Читы')
                end
                imgui.SameLine(77)
                if imgui.Button(u8'На 14 дней') then
                    sampSendChat('/ban '..spec_id..' 14 Читы')
                end
                imgui.SameLine(152)
                if imgui.Button(u8'На 30 дней') then
                    sampSendChat('/ban '..spec_id..' 30 Читы')
                end
                if imgui.Button(u8'По IP адресу') then
                    sampSendChat('/iban '..spec_id..' Читы')
                end
                imgui.Text(u8'————————————————————————————————')
                imgui.Text(u8'Введите время в 1 поле!\nВведите причину во 2 поле!')
                imgui.PushItemWidth(50)
                imgui.InputText(u8' ', ban, ffi.sizeof(ban))
                imgui.PopItemWidth()
                imgui.SameLine(83)
                imgui.PushItemWidth(130)
                imgui.InputText(u8' ', ban2, ffi.sizeof(ban2))
                imgui.PopItemWidth()
                if imgui.Button(u8'Забанить') then
                    sampSendChat(u8:decode('/ban '..spec_id..' '..ffi.string(ban)..' '..ffi.string(ban2)))
                end
                imgui.Text(u8'————————————————————————————————')
                if imgui.Button(u8'TK') then
                    sampSendChat('/warn '..spec_id..' TK')
                end
                imgui.SameLine(33)
                if imgui.Button(u8'СК') then
                    sampSendChat('/warn '..spec_id..' СК')
                end
                imgui.SameLine(58)
                if imgui.Button(u8'ПГ') then
                    sampSendChat('/warn '..spec_id..' ПГ')
                end
                imgui.SameLine(82)
                if imgui.Button(u8'РК') then
                    sampSendChat('/warn '..spec_id..' РК')
                end
                if imgui.Button(u8'Неадекват') then
                    sampSendChat('/warn '..spec_id..' Неадекват')
                end
                if imgui.Button(u8'ДМ в ЗЗ') then
                    sampSendChat('/warn '..spec_id..' ДМ в ЗЗ')
                end
                if imgui.Button(u8'Обсуждение действий адм.') then
                    sampSendChat('/warn '..spec_id..' Обсуждение действий адм.')
                end
            end
        imgui.End()
    end
)
 

ReoGenT

Участник
Автор темы
90
6

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,778
11,223
Не подскажешь как закрывать тему, просто я тут недавно :)
обычный пользователь не может закрыть тему, да и это не обязательно. Потом модератор может закрыть