Проблема с Imgui.Combo()

RICJS29_JSJA

Участник
Автор темы
88
3
Версия MoonLoader
Другое
sa-mp-161.png
Выбрал пост, пытаюсь ввести в отыгровке, пишет вместо него "2"
sa-mp-162.png
Как исправить?
 
Решение
Lua:
local post = imgui.ImInt(cfg.posti.post)

    if imgui.Combo(u8'Пост', post, {u8'Не выбрано', u8'Крыша хлева', u8'Поле', u8'Теплица', u8'Подвал'}, 5) then
        if post.v == 0 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 1 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 2 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 3 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 4 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        end...

RICJS29_JSJA

Участник
Автор темы
88
3
Как пример
Lua:
local combo_int = imgui.new.int(0)
local itemsList = {u8"Combo 1", u8"Combo 2", u8"Combo 3"}
local items = imgui.new['const char*'][#itemsList](itemsList)
imgui.Combo("combo", combo_int, items, #itemsList)

-- Вывод combo
print(u8:decode(itemsList[combo_int[0] + 1]))
не работает
 

RICJS29_JSJA

Участник
Автор темы
88
3
Lua:
local post = imgui.ImInt(cfg.posti.post)

    if imgui.Combo(u8'Пост', post, {u8'Не выбрано', u8'Крыша хлева', u8'Поле', u8'Теплица', u8'Подвал'}, 5) then
        if post.v == 0 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 1 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 2 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 3 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 4 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        end
    end
    
        if isKeyDown(VK_X) and isKeyJustPressed(VK_0) then
            sampAddChatMessage('/f ' .. u8:decode(cfg.settings.ftag) .. ' Заступаю на пост "' .. cfg.posti.post, -1)
        end
 

painw

Известный
116
63
Lua:
local post = imgui.ImInt(cfg.posti.post)

    if imgui.Combo(u8'Пост', post, {u8'Не выбрано', u8'Крыша хлева', u8'Поле', u8'Теплица', u8'Подвал'}, 5) then
        if post.v == 0 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 1 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 2 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 3 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        elseif post.v == 4 then
            cfg.posti.post = post.v
            inicfg.save(cfg, 'FPD_SCRIPT.ini')
        end
    end
   
        if isKeyDown(VK_X) and isKeyJustPressed(VK_0) then
            sampAddChatMessage('/f ' .. u8:decode(cfg.settings.ftag) .. ' Заступаю на пост "' .. cfg.posti.post, -1)
        end
Lua:
-- Вне имгуи
local post = imgui.ImInt(cfg.posti.post)
local list_combo = {u8'Не выбрано', u8'Крыша хлева', u8'Поле', u8'Теплица', u8'Подвал'}

-- В имгуи
if imgui.Combo(u8'Пост', post, list_combo, 5) then
    cfg.posti.post = post.v
    inicfg.save(cfg, 'FPD_SCRIPT.ini')
end

-- Бесконечный цикл
if isKeyDown(VK_X) and isKeyJustPressed(VK_0) then
    sampAddChatMessage('/f ' .. u8:decode(cfg.settings.ftag) .. ' Заступаю на пост "' .. u8:decode(list_combo[post.v+1]), -1)
end
 
  • Нравится
Реакции: RICJS29_JSJA