- 154
- 2
- Версия MoonLoader
- .026-beta
хоткей:
require 'lib.moonloader'
rkeys = require "rkeys"
imgui = require "imgui"
inicfg = require "inicfg"
enc = require "encoding"
enc.default = 'CP1251'
u8 = enc.UTF8
local directIni = "moonloader\\settings_lesson18.ini"
local mainIni = inicfg.load(nil, directIni)
imgui.HotKey = require('imgui_addons').HotKey
local MWS = imgui.ImBool(false)
if mainIni.hotkey == nil then
mainIni.hotkey = {
bindClock = "[18,82]",
bindPass = "[18,83]"
}
end
local tLastKeys = {}
local ActiveClockMenu = {
v = decodeJson(mainIni.hotkey.bindClock)
}
local ActivePassMenu = {
v = decodeJson(mainIni.hotkey.bindPass)
}
function main()
repeat wait(0) until isSampAvailable()
sampAddChatMessage("{00FF00}LOADED", -1)
imgui.Process = false
sampRegisterChatCommand('hotkey', function()
MWS.v = not MWS.v
imgui.Process = MWS.v
end)
bindClock = rkeys.registerHotKey(ActiveClockMenu.v, true, clockFunc)
bindPass = rkeys.registerHotKey(ActivePassMenu.v, true, clockPass)
while true do wait(0)
if MWS.v == false then imgui.Process = false end
end
end
function clockFunc()
sampAddChatMessage("true", -1)
end
function clockPass()
sampSendChat('/mm')
end
function imgui.OnDrawFrame()
imgui.Begin("lesson 18", MWS)
imgui.Text(u8"Настройка")
imgui.SameLine()
if imgui.HotKey("##1", ActiveClockMenu, tLastKeys, 100) then
rkeys.changeHotKey(bindClock, ActiveClockMenu.v)
sampAddChatMessage("Успешно! Старое значение: " .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActiveClockMenu.v), " + "), -1)
sampAddChatMessage("old meaning: " .. encodeJson(ActiveClockMenu.v), -1)
mainIni.hotkey.bindClock = encodeJson(ActiveClockMenu.v)
inicfg.save(mainIni, directIni)
end
imgui.Text(u8"Меню")
imgui.SameLine()
if imgui.HotKey("##2", ActivePassMenu, tLastKeys, 100) then
rkeys.changeHotKey(bindPass, ActivePassMenu.v)
sampAddChatMessage("Успешно! Старое значение: " .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(ActivePassMenu.v), " + "), -1)
sampAddChatMessage("old meaning: " .. encodeJson(ActivePassMenu.v), -1)
mainIni.hotkey.bindPass = encodeJson(ActivePassMenu.v)
inicfg.save(mainIni, directIni)
end
imgui.End()
end