- 1,093
- 296
- Версия MoonLoader
- .026-beta
Здарова, вот код:
Скрипт не вылетает, полностью работает, за исключением клавиш imgui.hotkey(rkeys)
LUA:
require 'lib.moonloader'
local sampev = require 'lib.samp.events'
local rkeys = require 'rkeys'
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
imgui.HotKey = require('imgui_addons').HotKey
local tLastKeys = {}
local ReportKey = {
v = decodeJson('[18,82]')
}
local bindReport = 0
local window = imgui.ImBool(false)
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('proverka', function()
window.v = not window.v
imgui.Process = window.v
end)
bindReport = rkeys.registerHotKey(ReportKey.v, false, function()
sampAddChatMessage('123', -1)
end)
while true do
wait(0)
end
end
function imgui.OnDrawFrame()
if not window.v then
imgui.Process = false
end
if window.v then
BH_theme()
local resX, resY = getScreenResolution()
local sizeX, sizeY = 300, 125 -- WINDOW SIZE
imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Автоловля репорта', window, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoMove)
imgui.PushFont(fontsize)
imgui.CenterText(fa.ICON_FA_FIRE .. u8' Автоловля репорта ' .. fa.ICON_FA_FIRE)
imgui.PopFont()
imgui.Separator()
imgui.Text(u8'Автоловля репорта')
imgui.SameLine()
if imgui.HotKey("##active", ReportKey, tLastKeys, 50) then
rkeys.changeHotKey(bindReport, ReportKey.v)
sampAddChatMessage('{68E7AF}[HotKey]{FFFFFF} Успешно изменен!', -1)
end
imgui.End()
end
end
function imgui.CenterText(text)
imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - imgui.CalcTextSize(text).x / 2)
imgui.Text(text)
end
function BH_theme() -- тема
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = ImVec2(6, 4)
style.WindowRounding = 5.0
style.ChildWindowRounding = 5.0
style.FramePadding = ImVec2(5, 2)
style.FrameRounding = 5.0
style.ItemSpacing = ImVec2(7, 5)
style.ItemInnerSpacing = ImVec2(1, 1)
style.TouchExtraPadding = ImVec2(0, 0)
style.IndentSpacing = 6.0
style.ScrollbarSize = 12.0
style.ScrollbarRounding = 5.0
style.GrabMinSize = 20.0
style.GrabRounding = 2.0
style.WindowTitleAlign = ImVec2(0.5, 0.5)
colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.28, 0.30, 0.35, 1.00)
colors[clr.WindowBg] = ImVec4(0.16, 0.18, 0.22, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.19, 0.22, 0.26, 1)
colors[clr.PopupBg] = ImVec4(0.05, 0.05, 0.10, 0.90)
colors[clr.Border] = ImVec4(0.19, 0.22, 0.26, 1.00)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.19, 0.22, 0.26, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.22, 0.25, 0.30, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.22, 0.25, 0.29, 1.00)
colors[clr.TitleBg] = ImVec4(0.19, 0.22, 0.26, 1.00)
colors[clr.TitleBgActive] = ImVec4(0.19, 0.22, 0.26, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.19, 0.22, 0.26, 0.59)
colors[clr.MenuBarBg] = ImVec4(0.19, 0.22, 0.26, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.20, 0.25, 0.30, 0.60)
colors[clr.ScrollbarGrab] = ImVec4(0.41, 0.55, 0.78, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.49, 0.63, 0.86, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.49, 0.63, 0.86, 1.00)
colors[clr.ComboBg] = ImVec4(0.20, 0.20, 0.20, 0.99)
colors[clr.CheckMark] = ImVec4(0.90, 0.90, 0.90, 0.50)
colors[clr.SliderGrab] = ImVec4(1.00, 1.00, 1.00, 0.30)
colors[clr.SliderGrabActive] = ImVec4(0.80, 0.50, 0.50, 1.00)
colors[clr.Button] = ImVec4(0.41, 0.55, 0.78, 1.00)
colors[clr.ButtonHovered] = ImVec4(0.49, 0.62, 0.85, 1.00)
colors[clr.ButtonActive] = ImVec4(0.49, 0.62, 0.85, 1.00)
colors[clr.Header] = ImVec4(0.19, 0.22, 0.26, 1.00)
colors[clr.HeaderHovered] = ImVec4(0.22, 0.24, 0.28, 1.00)
colors[clr.HeaderActive] = ImVec4(0.22, 0.24, 0.28, 1.00)
colors[clr.Separator] = ImVec4(0.41, 0.55, 0.78, 1.00)
colors[clr.SeparatorHovered] = ImVec4(0.41, 0.55, 0.78, 1.00)
colors[clr.SeparatorActive] = ImVec4(0.41, 0.55, 0.78, 1.00)
colors[clr.ResizeGrip] = ImVec4(0.41, 0.55, 0.78, 1.00)
colors[clr.ResizeGripHovered] = ImVec4(0.49, 0.61, 0.83, 1.00)
colors[clr.ResizeGripActive] = ImVec4(0.49, 0.62, 0.83, 1.00)
colors[clr.CloseButton] = ImVec4(0.41, 0.55, 0.78, 1.00)
colors[clr.CloseButtonHovered] = ImVec4(0.50, 0.63, 0.84, 1.00)
colors[clr.CloseButtonActive] = ImVec4(0.41, 0.55, 0.78, 1.00)
colors[clr.PlotLines] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(0.90, 0.70, 0.00, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.90, 0.70, 0.00, 1.00)
colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
colors[clr.TextSelectedBg] = ImVec4(0.41, 0.55, 0.78, 1.00)
colors[clr.ModalWindowDarkening] = ImVec4(0.16, 0.18, 0.22, 0.76)
end