local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local renderWindow = imgui.new.bool(true)
local FuncTimer = {
enabled = imgui.new.bool(false),
actve = false,
start_time = -1
}
local newFrame = imgui.OnFrame(
function() return renderWindow[0] end,
function(player)
local resX, resY = getScreenResolution()
local sizeX, sizeY = 300, 300
imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
imgui.Begin('Main Window', renderWindow)
if imgui.Checkbox('TimeFunction', FuncTimer.enabled) then
FuncTimer.active = FuncTimer.enabled[0]
if FuncTimer.enabled[0] then
FuncTimer.start_time = os.clock()
end
end
if FuncTimer.active then
imgui.Text('Disable in '..tostring(math.floor(FuncTimer.start_time + 16 - os.clock())))
end
imgui.End()
end
)
function main()
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand('mimgui', function()
renderWindow[0] = not renderWindow[0]
end)
while true do
wait(0)
----------------------------------------
if FuncTimer.active then
local time_left = math.floor(FuncTimer.start_time + 16 - os.clock()) -- тут прибавляем 16 вместо 15 так как math.floor округляет до меньшего
if time_left < 1 then
FuncTimer.active = false
FuncTimer.start_time = os.clock()
end
else
if FuncTimer.enabled[0] then
local time_left = math.floor(FuncTimer.start_time + 5 - os.clock())
if time_left < 1 then
FuncTimer.active = true
FuncTimer.start_time = os.clock()
end
end
end
----------------------------------------
if FuncTimer.active then
printStringNow('ENABLED', 50)
end
end
end