added module 2 mim timer

update
rubin 2 years ago
parent 8423a1ed6d
commit 26beb809a4
  1. 47
      mafia-tools.lua

@ -3,6 +3,8 @@ script_author("Serhiy_Rubin")
script_version("28.01.2023")
sampev = require 'samp.events'
inicfg = require "inicfg"
dlstatus = require("moonloader").download_status
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
@ -18,15 +20,41 @@ function main()
if server == "" then
thisScript():unload()
end
config.init()
lua_thread.create(timer_2min.loop)
while true do
wait(0)
wait(-1)
end
end
-->> 2 MIN TIMER
timer_2min = {}
timer_2min.onServerMessage = function(color, message)
if message:find("Война за бизнес .+ продлена на 2 минуты") then
config.data.time_2min = os.time()
config.save(config.data)
end
end
timer_2min.loop = function()
config.data.time_2min = os.time()
while true do
wait(0)
for a = 0, 2304 do
if sampTextdrawIsExists(a) then
local x, y = sampTextdrawGetPos(a)
if math.ceil(x) == 87 and math.ceil(y) == 256 then
local time = 120 - (os.time() - config.data.time_2min)
local text = string.format("%02d:%02d", math.floor(time / 60), time % 60)
if time < 120 and time >= 0 and sampTextdrawGetString(a) ~= text then
sampTextdrawSetString(a,text)
end
end
end
end
end
end
-->> CONFIG
config = {}
@ -81,6 +109,11 @@ config.read = function()
end
end
-->> EVENTS
function sampev.onServerMessage(color, message)
timer_2min.onServerMessage(color, message)
end
-->> UPDATE MODULE
function openURL(url, fpath)
local text = ""
@ -322,6 +355,4 @@ utf8({ "print" }, "Utf8ToAnsi")
utf8({ "renderGetFontDrawTextLength" }, "Utf8ToAnsi")
utf8({ "renderFontDrawText" }, "Utf8ToAnsi")
utf8({ "sampHasDialogRespond" }, nil, "AnsiToUtf8")
utf8({ "sampev", "onShowDialog" }, "AnsiToUtf8", "Utf8ToAnsi")
utf8({ "sampev", "onServerMessage" }, "AnsiToUtf8", "Utf8ToAnsi")
utf8({ "sampev", "onCreate3DText" }, "AnsiToUtf8", "Utf8ToAnsi")
utf8({ "sampev", "onServerMessage" }, "AnsiToUtf8", "Utf8ToAnsi")
Loading…
Cancel
Save