local rkeys = require 'rkeys'
imgui.HotKey = require('imgui_addons').HotKey
local tLastKeys = {}
local path = getGameDirectory()..'\\moonloader\\config\\hotkey.json'
local config = {
hot_key = {v = {VK_C}},
}
-- Load json
if not doesFileExist(path) then
local f = io.open(path, 'w+')
f:write(encodeJson(config)):close()
else
local f = io.open(path, "r")
a = f:read("*a")
config = decodeJson(a)
f:close()
end
-- Main
bind = rkeys.registerHotKey(config.hot_key.v, true, function()
-- Тут действие на HotKey. Принцип как у sampRegisterChatCommand вроде.
end)
-- OnDrawFrame
if imgui.HotKey("##1", config.hot_key, tLastKeys, 100) then
rkeys.changeHotKey(bind, config.hot_key.v)
JSONSave()
end
-- Save JSON
function JSONSave()
if doesFileExist(path) then
local f = io.open(path, 'w+')
if f then
f:write(encodeJson(config)):close()
end
end
end