Не запускается окно imgui

Kumi-_-

Участник
Автор темы
36
1
При запуске командой imgui крашит самп

Код:
function cmd_imgui(arg)
        main_window_state.v = not main_window_state.v
         imgui.Process = main_window_state.v
     end

     function cmd_check(arg)

     end

     function imgui.OnDrawFrame()

        imgui.Begin(u8"Заголовок", main_window_state)
        imgui.InputText(u8'Введите имя сюда', text_buffer_name)
        x, y, z = getCharCoordinates(PLAYER_PED)
        imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))

        imgui.RadioButton("Radio 1", checked_radio, 1)
      
        imgui.End()
        end
 

cort

Активный
244
98
При запуске командой imgui крашит самп

Код:
function cmd_imgui(arg)
        main_window_state.v = not main_window_state.v
         imgui.Process = main_window_state.v
     end

     function cmd_check(arg)

     end

     function imgui.OnDrawFrame()

        imgui.Begin(u8"Заголовок", main_window_state)
        imgui.InputText(u8'Введите имя сюда', text_buffer_name)
        x, y, z = getCharCoordinates(PLAYER_PED)
        imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))

        imgui.RadioButton("Radio 1", checked_radio, 1)
     
        imgui.End()
        end
В 11 строке напиши
Lua:
if main_window state then
и енд после imgui.End()
 

Corenale

луашер типа
Проверенный
177
369

Andrinall

Известный
702
527
Зачем тут "1" на конце?
C++:
IMGUI_API bool RadioButton(const char* label, bool active);
IMGUI_API bool RadioButton(const char* label, int* v, int v_button);
И тут зачем скобка перед "u8"
Lua:
imgui.Text(
    u8(
        "Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)
    )
) -- в u8 объединяется строка целиком, чтобы не применять u8 к каждой строке при конкатенации, для того и нужны скобки
 

Corenale

луашер типа
Проверенный
177
369
C++:
IMGUI_API bool RadioButton(const char* label, bool active);
IMGUI_API bool RadioButton(const char* label, int* v, int v_button);

Lua:
imgui.Text(
    u8(
        "Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)
    )
) -- в u8 объединяется строка целиком, чтобы не применять u8 к каждой строке при конкатенации, для того и нужны скобки
А оке понял...
 

Andrinall

Известный
702
527
При запуске командой imgui крашит самп

Код:
function cmd_imgui(arg)
        main_window_state.v = not main_window_state.v
         imgui.Process = main_window_state.v
     end

     function cmd_check(arg)

     end

     function imgui.OnDrawFrame()

        imgui.Begin(u8"Заголовок", main_window_state)
        imgui.InputText(u8'Введите имя сюда', text_buffer_name)
        x, y, z = getCharCoordinates(PLAYER_PED)
        imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))

        imgui.RadioButton("Radio 1", checked_radio, 1)
  
        imgui.End()
        end
Вот рабочий вариант, сравнивай со своим и делай необходимые выводы.
Lua:
local imgui = require 'imgui'
local encoding = require 'encoding'

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

local main_window_state = imgui.ImBool(false)
local checked_radio = imgui.ImBool(false)
local text_buffer_name = imgui.ImBuffer(256)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    repeat wait(100) until isSampAvailable()
  
    sampRegisterChatCommand('/imgui', cmd_imgui)
  
    wait(-1)
end

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

function cmd_check(arg)
end

function imgui.OnDrawFrame()
    imgui.Begin(u8"Заголовок", main_window_state)
    imgui.InputText(u8'Введите имя сюда', text_buffer_name)
  
    x, y, z = getCharCoordinates(PLAYER_PED)
    imgui.Text(u8("Позиция игрока: X:" .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z)))
  
  
    if imgui.RadioButton("Radio 1", checked_radio.v) then
        checked_radio.v = not checked_radio.v
    end
    -- здесь убрать 1 и поменять checked_radio на checked_radio.v (передаёшь userdata вместо bool)
    -- по поводу этой единицы всё таки Corenale прав(-а), в moon imgui нет перегрузки этой функции из-за чего доступен только 1 вариант.
  
    imgui.End()
end
1651737951086.png
 
  • Нравится
Реакции: Corenale и Kumi-_-