require "lib.moonloader"
local imgui = require 'imgui'
local sampev = require 'samp.events'
local encoding = require('lib.encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
function FormatTime(time)
local timezone_offset = 86400 - os.date('%H', 0) * 3600
local time = time + timezone_offset
return os.date((os.date("%H",time) == "00" and '%M:%S' or '%H:%M:%S'), time)
end
function sampev.onServerMessage(color, text)
if text:find('(%w+_%w+) (.+) спровоцировал(а) захват территории банды (.+)') then --Сам
timerStart = os.time()
timerEndTime = 10
main_window_state.v = true
end
end
function imgui.OnDrawFrame()
if main_window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(150, 200), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2(50,300), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Таймер', main_window_state, imgui.WindowFlags.NoMove + imgui.WindowFlags.NoResize)
if timerStart and timerEndTime and main_window_state.v then
local timerEndTimeSec = timerEndTime * 60
local showtime = timerEndTimeSec - (os.time() - timerStart)
if showtime > 0 then
imgui.Text(u8'Осталось: '..FormatTime(showtime))
else
printStyledString("Time's up", 1000, 4)
main_window_state.v = not main_window_state.v
end
end
if imgui.Button(u8'Деактивация') then -- а вот и кнопка с действием
main_window_state.v = not main_window_state.v
end
imgui.End()
end
end
function main()
while true do wait(0)
imgui.ShowCursor = false
imgui.Process = main_window_state.v
end
end