Исходник mimgui hotkey - 027, 026 moonloader

dmitry.karle

Активный
Автор темы
353
93
Представляю к вашему вниманию свою библиотеку хоткеев для moonloader 027 и для 026 с готовым и приятным GUI для глаза (mimgui + moonmonet). Вроде бы ещё не было библиотеки для moonloader 027 , но теперь она есть и работает нормально, и не выбивает таблицу.

Под основной код был взят код: https://www.blast.hk/threads/178867/
И переделан под 027.

xqPukJkZ_0M.jpg


Для установки библиотеки:
moonloader/lib

Как пользоваться:

Lua:
local hotkey = require 'mimgui_hotkey'
local imgui = require 'mimgui'
local inicfg = require 'inicfg'
local config = inicfg.load({
    bindhotkey = {
        hotkey1 = '18, 49', --две клавиши
        hotkey2 = '45', --одна клавиша
        hotkey3 = '', --пустая клавиша
    },
}, 'inifile.ini')
inicfg.save(config, 'inifile.ini')

function main()
repeat wait(0) until isSampAvailable()
t1 = hotkey.RegisterHotKey('t1', false, stringToKeys(config.bindhotkey.hotkey1), function() sampAddChatMessage('hotkey1', -1) end)
t2 = hotkey.RegisterHotKey('t2', false, stringToKeys(config.bindhotkey.hotkey2), function() sampAddChatMessage('hotkey2', -1) end)
t3 = hotkey.RegisterHotKey('t3', false, stringToKeys(config.bindhotkey.hotkey3), function() sampAddChatMessage('hotkey3', -1) end)
    while true do wait(0)
    end
end


--во фрейме
if t1:ShowHotKey(imgui.ImVec2(150, 25)) then
    if config.bindhotkey.hotkey1 ~= keysToString(t1:GetHotKey()) then
        config.bindhotkey.hotkey1 = keysToString(t1:GetHotKey())
        inicfg.save(config, 'inifile.ini')
    end
    t1:EditHotKey(t1:GetHotKey())
end; imgui.SameLine(nil, 5); imgui.Text(u8'Хоткеи 1')
if t2:ShowHotKey(imgui.ImVec2(150, 25)) then
    if config.bindhotkey.hotkey2 ~= keysToString(t2:GetHotKey()) then
        config.bindhotkey.hotkey2 = keysToString(t2:GetHotKey())
        inicfg.save(config, 'inifile.ini')
    end
    t2:EditHotKey(t2:GetHotKey())
end; imgui.SameLine(nil, 5); imgui.Text(u8'Хоткеи 2')
if t3:ShowHotKey(imgui.ImVec2(150, 25)) then
    if config.bindhotkey.hotkey3 ~= keysToString(t3:GetHotKey()) then
        config.bindhotkey.hotkey3 = keysToString(t3:GetHotKey())
        inicfg.save(config, 'inifile.ini')
    end
    t3:EditHotKey(t3:GetHotKey())
end; imgui.SameLine(nil, 5); imgui.Text(u8'Хоткеи 3')
 

Вложения

  • mimgui_hotkey.lua
    17.6 KB · Просмотры: 0
  • Нравится
Реакции: VanoKLR

dmitry.karle

Активный
Автор темы
353
93
Бинды на клавиши мыши есть?
Хотел сделать, на быковые клавиши, они в библиотеки vkeys есть, но чёт они не хотели ставиться на тот момент и забил на эти клавиши. Причём если вручную ставить, то всё работает