краш при активации imgui окна

deadfamq

Участник
Автор темы
107
22
Версия MoonLoader
.026-beta
ку, крашит после использования второго imgui окна
Lua:
    if khelp.v then
        imgui.SetNextWindowSize(imgui.ImVec2(100, 100), imgui.Cond.FirstUseEver)
        local sW, sH = getScreenResolution()

        imgui.SetNextWindowPos(imgui.ImVec2(sW / 2, sH / 2), imgui.Cond.ImGuiCond_Always, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8"sexywindow", khelp, imgui.WindowFlags.NoResize)
        if imgui.Button(u8'кнопка') then
            sampAddChatMessage('test', -1)
        end
    end
 
Решение
Lua:
script_author("stolyarboss")
script_name("koryaga")
script_description("tipo lol alo idi nahuy daun")

local key = require('vkeys')
local ev = require('lib.samp.events')
local inicfg = require("inicfg")

local imgui = require('imgui')

local encoding = require("encoding")
encoding.default = 'CP1251'
u8 = encoding.UTF8

local maini = imgui.ImBool(false)
local khelp = imgui.ImBool(false)

local selected_item = imgui.ImInt(0)
local checked_radio = imgui.ImInt(1)
local themes = import "resource/imgui_themes.lua"

local tag = '[GovnoCoder]'

function main()
    if not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
        imgui.SwitchContext()
        themes.SwitchColorTheme()

    sampAddChatMessage(tag.."скрипт...

qdIbp

Автор темы
Проверенный
1,435
1,175
Lua:
    if khelp.v then
        local sW, sH = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(100, 100), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(sW / 2, sH / 2), imgui.Cond.ImGuiCond_Always, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8"sexywindow", khelp, imgui.WindowFlags.NoResize)
            if imgui.Button(u8'кнопка') then
                sampAddChatMessage('test', -1)
            end
        imgui.End()
    end
 
  • Нравится
Реакции: deadfamq

deadfamq

Участник
Автор темы
107
22
Lua:
    if khelp.v then
        local sW, sH = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(100, 100), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(sW / 2, sH / 2), imgui.Cond.ImGuiCond_Always, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8"sexywindow", khelp, imgui.WindowFlags.NoResize)
            if imgui.Button(u8'кнопка') then
                sampAddChatMessage('test', -1)
            end
        imgui.End()
    end
все равно крашит, на текста не обращайте внимание..
code:
script_author("stolyarboss")
script_name("koryaga")
script_description("tipo lol alo idi nahuy daun")


local imgui = require 'imgui'
local encoding = require "encoding"
local inicfg = require("inicfg")
local key = require 'vkeys'
local ev = require('lib.samp.events')

local themes = import "resource/imgui_themes.lua"

local maini = imgui.ImBool(false)
local khelp = imgui.ImBool(false)

local selected_item = imgui.ImInt(0)
local checked_radio = imgui.ImInt(1)

encoding.default = 'CP1251'
u8 = encoding.UTF8


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

imgui.Process = false

    imgui.SwitchContext()
    themes.SwitchColorTheme()

    sampAddChatMessage( tag.."скрипт запущен.", -1)
    sampAddChatMessage( tag.."активация - /koryaga & F3", -1)

     sampRegisterChatCommand("koryaga", koryagah)
     sampRegisterChatCommand('khelp', koryagahelp)

    while true do wait(0)
        imgui.ShowCursor = maini.v
        if wasKeyPressed(key.VK_F3) then
            maini.v = not maini.v
        end
        imgui.Process = maini.v or khelp.v
    end
end

function koryagah()
    maini.v = not maini.v
    imgui.Process = maini.v
end

function koryagahelp()
    khelp.v = not khelp.v
    imgui.Process = khelp.v
end

function imgui.TextQuestion(label, description)
    imgui.TextDisabled(label)

    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
            imgui.PushTextWrapPos(600)
                imgui.TextUnformatted(description)
            imgui.PopTextWrapPos()
        imgui.EndTooltip()
    end
end


function imgui.OnDrawFrame()
    if maini.v then
        imgui.SetNextWindowSize(imgui.ImVec2(800, 350), imgui.Cond.FirstUseEver)
        local sW, sH = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sW / 2, sH / 2), imgui.Cond.ImGuiCond_Always, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8"Коряга",maini, imgui.WindowFlags.NoResize)
        if imgui.Button(u8'нажми') then
            sampAddChatMessage(tag..'аа соси хуй лошара', -1)
        end
        imgui.SameLine()
        if imgui.Button(u8'сохранить') then
            sampAddChatMessage(tag..'аа соси хуй лошара', -1)
        end
        imgui.SameLine()
        imgui.TextQuestion("( ? )", u8"сохранение настроек скрипта.")
        imgui.Separator()
        imgui.BeginChild("ChildWindow2", imgui.ImVec2(200, 175), true)
            for i, value in ipairs(themes.colorThemes) do
                if imgui.RadioButton(value, checked_radio, i) then
                    themes.SwitchColorTheme(i)
                end
            end
        imgui.EndChild()
        imgui.End()
    end
    if khelp.v then
        local sW, sH = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(100, 100), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(sW / 2, sH / 2), imgui.Cond.ImGuiCond_Always, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8"sexywindow", khelp, imgui.WindowFlags.NoResize)
            if imgui.Button(u8'кнопка') then
                sampAddChatMessage('test', -1)
            end
        imgui.End()
    end
end
 

qdIbp

Автор темы
Проверенный
1,435
1,175
Lua:
script_author("stolyarboss")
script_name("koryaga")
script_description("tipo lol alo idi nahuy daun")

local key = require('vkeys')
local ev = require('lib.samp.events')
local inicfg = require("inicfg")

local imgui = require('imgui')

local encoding = require("encoding")
encoding.default = 'CP1251'
u8 = encoding.UTF8

local maini = imgui.ImBool(false)
local khelp = imgui.ImBool(false)

local selected_item = imgui.ImInt(0)
local checked_radio = imgui.ImInt(1)
local themes = import "resource/imgui_themes.lua"

local tag = '[GovnoCoder]'

function main()
    if not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
        imgui.SwitchContext()
        themes.SwitchColorTheme()

    sampAddChatMessage(tag.."скрипт запущен.", -1)
    sampAddChatMessage(tag.."активация - /koryaga & F3", -1)

     sampRegisterChatCommand("koryaga", function() maini.v = not maini.v end)
     sampRegisterChatCommand('khelp', function() khelp.v = not khelp.v end)

    while true do wait(0)
        imgui.ShowCursor = maini.v
        if wasKeyPressed(key.VK_F3) then
            maini.v = not maini.v
        end
        imgui.Process = maini.v or khelp.v
    end
end

function imgui.TextQuestion(label, description)
    imgui.TextDisabled(label)

    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
            imgui.PushTextWrapPos(600)
                imgui.TextUnformatted(description)
            imgui.PopTextWrapPos()
        imgui.EndTooltip()
    end
end


function imgui.OnDrawFrame()
    local sW, sH = getScreenResolution()
    if maini.v then
        imgui.SetNextWindowSize(imgui.ImVec2(800, 350), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(sW / 2, sH / 2), imgui.Cond.ImGuiCond_Always, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8"Коряга",maini, imgui.WindowFlags.NoResize)
            if imgui.Button(u8'нажми') then
                sampAddChatMessage(tag..'аа соси хуй лошара', -1)
            end
            imgui.SameLine()
            if imgui.Button(u8'сохранить') then
                sampAddChatMessage(tag..'аа соси хуй лошара', -1)
            end
            imgui.SameLine()
            imgui.TextQuestion("( ? )", u8"сохранение настроек скрипта.")
            imgui.Separator()
            imgui.BeginChild("ChildWindow2", imgui.ImVec2(200, 175), true)
                for i, value in ipairs(themes.colorThemes) do
                    if imgui.RadioButton(value, checked_radio, i) then
                        themes.SwitchColorTheme(i)
                    end
                end
            imgui.EndChild()
        imgui.End()
    end
    if khelp.v then
        imgui.SetNextWindowSize(imgui.ImVec2(100, 100), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2(sW / 2, sH / 2), imgui.Cond.ImGuiCond_Always, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8"sexywindow", khelp, imgui.WindowFlags.NoResize)
            if imgui.Button(u8'кнопка') then
                sampAddChatMessage('test', -1)
            end
        imgui.End()
    end
end
 
  • Нравится
Реакции: deadfamq