local vk = require "vkeys"
local imgui = require "imgui"
local ui_meta = {
__index = function(self, v)
if v == "switch" then
local switch = function()
if self.process and self.process:status() ~= "dead" then
return false
end
self.timer = os.clock()
self.state = not self.state
self.process = lua_thread.create(function()
local bringFloatTo = function(from, to, start_time, duration)
local timer = os.clock() - start_time
if timer >= 0.00 and timer <= duration then
local count = timer / (duration / 100)
return count * ((to - from) / 100)
end
return (timer > duration) and to or from
end
while true do wait(0)
local a = bringFloatTo(0.00, 1.00, self.timer, self.duration)
self.alpha = self.state and a or 1.00 - a
if a == 1.00 then break end
end
end)
return true
end
return switch
end
if v == "alpha" then
return self.state and 1.00 or 0.00
end
end
}
local menu = { state = false, duration = 0.5 }
setmetatable(menu, ui_meta)
local info = { state = false, duration = 1.0 }
setmetatable(info, ui_meta)
function main()
repeat wait(0) until isSampAvailable()
sampRegisterChatCommand("menu", menu.switch)
sampRegisterChatCommand("info", info.switch)
while true do
imgui.Process = (menu.alpha > 0.00) or (info.alpha > 0.00)
imgui.ShowCursor = menu.state or info.state
if isKeyJustPressed(vk.VK_F2) then
if info.alpha > 0.00 then info.switch() end
menu.switch()
end
if isKeyJustPressed(vk.VK_F4) then
if menu.alpha > 0.00 then menu.switch() end
info.switch()
end
wait(0)
end
end
function imgui.OnDrawFrame()
if menu.alpha > 0.00 then
imgui.PushStyleVar(imgui.StyleVar.Alpha, menu.alpha)
imgui.Begin("##My window", _, imgui.WindowFlags.NoTitleBar)
imgui.Text("111")
-- // Code..
imgui.End()
imgui.PopStyleVar()
end
if info.alpha > 0.00 then
imgui.PushStyleVar(imgui.StyleVar.Alpha, info.alpha)
imgui.Begin("##Information", _, imgui.WindowFlags.NoTitleBar)
imgui.Text("222")
-- // Code..
imgui.End()
imgui.PopStyleVar()
end
end