Проблема imgui

MrCH

Участник
Автор темы
109
17
Версия MoonLoader
.026-beta
Написал биндер для личного использования, он работает как задумывалось, однако напрягает то, что при выборе элемента в выпадающем списке не меняется этот текст(на скрине). Как это можно исправить?
Безымянный.png
 
Решение
lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
local set


local test_text_buffer = imgui.ImBuffer(256)
function imgui.OnDrawFrame()
  selected_item = imgui.ImInt(0)
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(300, 300), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Отыгровки', main_window_state)
    imgui.PushItemWidth(100)
    if imgui.Combo(u8'Выбери тип отыгровки', selected_item, {'Passport', 'Licenses', 'MedCard'}, 3) then
      if selected_item.v == 0 then
        set = 1
      end
      if selected_item.v == 1 then
          set = 2
      end
      if...

why ega

РП игрок
Модератор
2,541
2,233

MrCH

Участник
Автор темы
109
17
lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
local set


local test_text_buffer = imgui.ImBuffer(256)
function imgui.OnDrawFrame()
  selected_item = imgui.ImInt(0)
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(300, 300), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Отыгровки', main_window_state)
    imgui.PushItemWidth(100)
    if imgui.Combo(u8'Выбери тип отыгровки', selected_item, {'Passport', 'Licenses', 'MedCard'}, 3) then
      if selected_item.v == 0 then
        set = 1
      end
      if selected_item.v == 1 then
          set = 2
      end
      if selected_item.v == 2 then
          set = 3
      end
    end
    if imgui.InputText(u8'Введите id', test_text_buffer, imgui.ImVec2(100, 50)) then 
      imgui.PopItemWidth()
    end
    imgui.SetNextWindowSize(imgui.ImVec2(150, 200), imgui.Cond.FirstUseEver)
      if imgui.Button(u8'Пуск') then -- а вот и кнопка с действием
        if set == 1 then
          lua_thread.create(function()
            sampSendChat('/do Папка с документами в руках.')
              wait(1000)
            sampSendChat('/me отркыл папку и достал пасспорт')
              wait(1000)
            sampSendChat('/do Пасспорт в руке.')
              wait(1000)
            sampSendChat('/me передал пасспорт человеку напротив')
              wait(1000)
            sampSendChat("/showpass " .. test_text_buffer.v)
          end)
        end
        if set == 2 then
          lua_thread.create(function()
            sampSendChat('/do Папка с документами в руках.')
              wait(1000)
            sampSendChat('/do Папка открыта.')
              wait(1000)
            sampSendChat('/me достал из папки лицензии')
            wait(1000)
            sampSendChat('/do Лицензии в руках.')
              wait(1000)
            sampSendChat('/me передал лицензии человеку напротив')
            wait(1000)
            sampSendChat("/showlic " .. test_text_buffer.v)
          end)
        end
        if set == 3 then
          lua_thread.create(function()
            sampSendChat('/do Папка с документами в руках.')
              wait(1000)
            sampSendChat('/do Папка открыта.')
              wait(1000)
            sampSendChat('/me достал из папки медицинскую карту')
            wait(1000)
            sampSendChat('/do Медицинская карта в руках.')
              wait(1000)
            sampSendChat('/me передал медицинскую карту человеку напротив')
              wait(1000)
            sampSendChat("/showmc " .. test_text_buffer.v)
          end)
        end
    end
  imgui.End()
  end
end

function main()
    while true do
        wait(0)
        if wasKeyPressed(key.VK_X) then
            main_window_state.v = not main_window_state.v
        end
        imgui.Process = main_window_state.v
      end
  end
 

PanSeek

t.me/dailypanseek
Всефорумный модератор
899
1,745
lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
local set


local test_text_buffer = imgui.ImBuffer(256)
function imgui.OnDrawFrame()
  selected_item = imgui.ImInt(0)
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(300, 300), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Отыгровки', main_window_state)
    imgui.PushItemWidth(100)
    if imgui.Combo(u8'Выбери тип отыгровки', selected_item, {'Passport', 'Licenses', 'MedCard'}, 3) then
      if selected_item.v == 0 then
        set = 1
      end
      if selected_item.v == 1 then
          set = 2
      end
      if selected_item.v == 2 then
          set = 3
      end
    end
    if imgui.InputText(u8'Введите id', test_text_buffer, imgui.ImVec2(100, 50)) then
      imgui.PopItemWidth()
    end
    imgui.SetNextWindowSize(imgui.ImVec2(150, 200), imgui.Cond.FirstUseEver)
      if imgui.Button(u8'Пуск') then -- а вот и кнопка с действием
        if set == 1 then
          lua_thread.create(function()
            sampSendChat('/do Папка с документами в руках.')
              wait(1000)
            sampSendChat('/me отркыл папку и достал пасспорт')
              wait(1000)
            sampSendChat('/do Пасспорт в руке.')
              wait(1000)
            sampSendChat('/me передал пасспорт человеку напротив')
              wait(1000)
            sampSendChat("/showpass " .. test_text_buffer.v)
          end)
        end
        if set == 2 then
          lua_thread.create(function()
            sampSendChat('/do Папка с документами в руках.')
              wait(1000)
            sampSendChat('/do Папка открыта.')
              wait(1000)
            sampSendChat('/me достал из папки лицензии')
            wait(1000)
            sampSendChat('/do Лицензии в руках.')
              wait(1000)
            sampSendChat('/me передал лицензии человеку напротив')
            wait(1000)
            sampSendChat("/showlic " .. test_text_buffer.v)
          end)
        end
        if set == 3 then
          lua_thread.create(function()
            sampSendChat('/do Папка с документами в руках.')
              wait(1000)
            sampSendChat('/do Папка открыта.')
              wait(1000)
            sampSendChat('/me достал из папки медицинскую карту')
            wait(1000)
            sampSendChat('/do Медицинская карта в руках.')
              wait(1000)
            sampSendChat('/me передал медицинскую карту человеку напротив')
              wait(1000)
            sampSendChat("/showmc " .. test_text_buffer.v)
          end)
        end
    end
  imgui.End()
  end
end

function main()
    while true do
        wait(0)
        if wasKeyPressed(key.VK_X) then
            main_window_state.v = not main_window_state.v
        end
        imgui.Process = main_window_state.v
      end
  end
Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local main_window_state = imgui.ImBool(false)
local test_text_buffer = imgui.ImBuffer(256)
local selected_item = imgui.ImInt(0)
local arr_items = {
  'Passport',
  'Licenses',
  'MedCard'
}

function imgui.OnDrawFrame()
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(300, 300), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Отыгровки', main_window_state)

    imgui.PushItemWidth(100)
    imgui.Combo(u8'Выбери тип отыгровки', selected_item, arr_items, #arr_items)
    imgui.InputText(u8'Введите id', test_text_buffer, imgui.ImVec2(100, 50))
    imgui.PopItemWidth()

    if imgui.Button(u8'Пуск') then
      if selected_item.v == 0 then
        lua_thread.create(function()
          sampSendChat('/do Папка с документами в руках.')
            wait(1000)
          sampSendChat('/me отркыл папку и достал пасспорт')
            wait(1000)
          sampSendChat('/do Пасспорт в руке.')
            wait(1000)
          sampSendChat('/me передал пасспорт человеку напротив')
            wait(1000)
          sampSendChat("/showpass " .. test_text_buffer.v)
        end)
      end
      if selected_item.v == 1 then
        lua_thread.create(function()
          sampSendChat('/do Папка с документами в руках.')
            wait(1000)
          sampSendChat('/do Папка открыта.')
            wait(1000)
          sampSendChat('/me достал из папки лицензии')
            wait(1000)
          sampSendChat('/do Лицензии в руках.')
            wait(1000)
          sampSendChat('/me передал лицензии человеку напротив')
            wait(1000)
          sampSendChat("/showlic " .. test_text_buffer.v)
        end)
      end
      if selected_item.v == 2 then
        lua_thread.create(function()
          sampSendChat('/do Папка с документами в руках.')
            wait(1000)
          sampSendChat('/do Папка открыта.')
            wait(1000)
          sampSendChat('/me достал из папки медицинскую карту')
          wait(1000)
          sampSendChat('/do Медицинская карта в руках.')
            wait(1000)
          sampSendChat('/me передал медицинскую карту человеку напротив')
            wait(1000)
          sampSendChat("/showmc " .. test_text_buffer.v)
        end)
      end
    end
  imgui.End()
  end
end

function main()
  while true do wait(0)
    if wasKeyPressed(key.VK_X) then
      main_window_state.v = not main_window_state.v
    end
    imgui.Process = main_window_state.v
  end
end
 
  • Нравится
  • Клоун
Реакции: Fott и MrCH