Краш игры

Slava Stetem

Участник
Автор темы
106
5
Версия MoonLoader
.027.0-preview
Кароче написал код по тему ImGUI и при активации главного меню крашит игру вот ошибка
nmg9tYO.png

а вот код:
Lua:
require "lib.moonloader"

local rkeys = require("rkeys")
local imgui = require 'imgui'
local encoding = require("encoding")

local main_window_state = imgui.ImBool(false)

local u8 = encoding.UTF8
encoding.default = "CP1251"

function imgui.OnDrawFrame()
    if main_window_state.v then
        local x, y = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(x/2, y/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(850, 535), imgui.Cond.FirstUseEver)
        imgui.Begin(u8" New",  main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)

        imgui.Columns(2,"", true)
        imgui.SetColumnWidth(-1, 232)
        imgui.BeginChild("##menubok", imgui.ImVec2(225, 500), true, imgui.WindowFlags.NoScrollbar)
        if imgui.Button('1',imgui.ImVec2(210, 45)) then
            menu = 1
        end
        imgui.SameLine()
        if imgui.Button('2',imgui.ImVec2(210, 45)) then
            menu = 2
        end
        imgui.EndChild()
        imgui.BeginChild("##new")
        if menu == 1 then
            if imgui.Button(u8'Сказать привет',imgui.ImVec2(210, 45)) then
                sampSendChat(u8"Привет")
            end
        end
        imgui.EndChild()
    end
end

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

    while true do wait(0) imgui.Process = true

    if isKeyJustPressed(VK_1) and not sampIsChatInputActive() and not isSampfuncsConsoleActive() then
        main_window_state.v = not main_window_state.v
    end

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

Mico

Активный
246
46
Кароче написал код по тему ImGUI и при активации главного меню крашит игру вот ошибка
nmg9tYO.png

а вот код:
Lua:
require "lib.moonloader"

local rkeys = require("rkeys")
local imgui = require 'imgui'
local encoding = require("encoding")

local main_window_state = imgui.ImBool(false)

local u8 = encoding.UTF8
encoding.default = "CP1251"

function imgui.OnDrawFrame()
    if main_window_state.v then
        local x, y = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(x/2, y/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(850, 535), imgui.Cond.FirstUseEver)
        imgui.Begin(u8" New",  main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)

        imgui.Columns(2,"", true)
        imgui.SetColumnWidth(-1, 232)
        imgui.BeginChild("##menubok", imgui.ImVec2(225, 500), true, imgui.WindowFlags.NoScrollbar)
        if imgui.Button('1',imgui.ImVec2(210, 45)) then
            menu = 1
        end
        imgui.SameLine()
        if imgui.Button('2',imgui.ImVec2(210, 45)) then
            menu = 2
        end
        imgui.EndChild()
        imgui.BeginChild("##new")
        if menu == 1 then
            if imgui.Button(u8'Сказать привет',imgui.ImVec2(210, 45)) then
                sampSendChat(u8"Привет")
            end
        end
        imgui.EndChild()
    end
end

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

    while true do wait(0) imgui.Process = true

    if isKeyJustPressed(VK_1) and not sampIsChatInputActive() and not isSampfuncsConsoleActive() then
        main_window_state.v = not main_window_state.v
    end

    if main_window_state.v == false then
        imgui.Process = false
    end
end
end
Функцию с IMGUI перенеси под while true do ... end
Ты еще забыл про imgui.End()
Lua:
function imgui.OnDrawFrame()
    if main_window_state.v then
        local x, y = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(x/2, y/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(850, 535), imgui.Cond.FirstUseEver)
        imgui.Begin(u8" New",  main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)

        imgui.Columns(2,"", true)
        imgui.SetColumnWidth(-1, 232)
        imgui.BeginChild("##menubok", imgui.ImVec2(225, 500), true, imgui.WindowFlags.NoScrollbar)
        if imgui.Button('1',imgui.ImVec2(210, 45)) then
            menu = 1
        end
        imgui.SameLine()
        if imgui.Button('2',imgui.ImVec2(210, 45)) then
            menu = 2
        end
        imgui.EndChild()
        imgui.BeginChild("##new")
        if menu == 1 then
            if imgui.Button(u8'Сказать привет',imgui.ImVec2(210, 45)) then
                sampSendChat(u8"Привет")
            end
        end
        imgui.EndChild()
        imgui.End()
    end
end
 

Kolbasa241

Известный
213
57
Lua:
require "lib.moonloader"
local imgui = require 'imgui'
local rkeys = require("rkeys")
local encoding = require("encoding")

local main_window_state = imgui.ImBool(false)

local u8 = encoding.UTF8
encoding.default = "CP1251"

function main()
      if not isSampfuncsLoaded() or not isSampLoaded() then return end
      while not isSampAvailable() do wait(100) end
      imgui.Process = false
    while true do wait(0)
        
        if isKeyJustPressed(VK_1) and not sampIsChatInputActive() and not isSampfuncsConsoleActive() then
            main_window_state.v = not main_window_state.v
        end
        imgui.Process = main_window_state.v
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        local x, y = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(x/2, y/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(850, 535), imgui.Cond.FirstUseEver)
        imgui.Begin(u8" New",  main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)

            imgui.Columns(2,"", true)
            imgui.SetColumnWidth(-1, 232)
            imgui.BeginChild("##menubok", imgui.ImVec2(225, 500), true, imgui.WindowFlags.NoScrollbar)
                if imgui.Button('1',imgui.ImVec2(210, 45)) then
                    menu = 1
                end
                if imgui.Button('2',imgui.ImVec2(210, 45)) then
                    menu = 2
                end
                if menu == 1 then
                    if imgui.Button(u8'Сказать привет',imgui.ImVec2(210, 45)) then
                        sampSendChat(u8"Привет")
                    end
                end
            imgui.EndChild()
        imgui.End()
    end
end