- Версия MoonLoader
- .026-beta
LUA:
local file = getWorkingDirectory() .. "\\config\\binds.bind"
local tEditData = {
id = -1,
inputActive = false
}
local tBindList = {}
if doesFileExist(file) then
local f = io.open(file, "r")
if f then
tBindList = decodeJson(f:read("a*"))
f:close()
end
else
tBindList = {
[1] = {
text = "123",
v = {vkeys.VK_P}
}
}
end
function main()
бла бла бла...
for k, v in pairs(tBindList) do
rkeys.registerHotKey(v.v, true, onHotKey)
end
end
function imgui.OnDrawFrame()
бла бла бла ...
for k, v in ipairs(tBindList) do
if hk.HotKey("##HK" .. k, v, tLastKeys, 100) then
if not rkeys.isHotKeyDefined(v.v) then
if rkeys.isHotKeyDefined(tLastKeys.v) then
rkeys.unRegisterHotKey(tLastKeys.v)
end
rkeys.registerHotKey(v.v, true, onHotKey)
end
end
imgui.SameLine()
if tEditData.id ~= k then
local sText = v.text:gsub("%[enter%]$", "")
imgui.BeginChild("##cliclzone" .. k, imgui.ImVec2(500, 21))
imgui.AlignTextToFramePadding()
if sText:len() > 0 then
imgui.Text(u8(sText))
else
imgui.TextDisabled(u8("Пустое сообщение ..."))
end
imgui.EndChild()
if imgui.IsItemClicked() then
sInputEdit.v = sText:len() > 0 and u8(sText) or ""
bIsEnterEdit.v = string.match(v.text, "(.)%[enter%]$") ~= nil
tEditData.id = k
tEditData.inputActve = true
end
else
imgui.PushAllowKeyboardFocus(false)
imgui.PushItemWidth(500)
local save = imgui.InputText("##Edit" .. k, sInputEdit, imgui.InputTextFlags.EnterReturnsTrue)
imgui.PopItemWidth()
imgui.PopAllowKeyboardFocus()
imgui.SameLine()
imgui.Checkbox(u8("Ввод") .. "##editCH" .. k, bIsEnterEdit)
if save then
tBindList[tEditData.id].text = u8:decode(sInputEdit.v) .. (bIsEnterEdit.v and "[enter]" or "")
tEditData.id = -1
end
if tEditData.inputActve then
tEditData.inputActve = false
imgui.SetKeyboardFocusHere(-1)
end
end
end
end
LUA:
if isKeyJustPressed(кнопка которую забиндил) and not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive() then
rpmod.v = not rpmod.v
if rpmod.v then
sampAddChatMessage("[DRPHelper]: {FFFFFF}РП мод {04FF00}активирован.", 0x5A90CE)
else
sampAddChatMessage("[DRPHelper]: {FFFFFF}РП мод {FF1212}деактивирован.", 0x5A90CE)
end
end