local sampev = require("lib.samp.events")
local inicfg = require("inicfg")
local mainIni = inicfg.load({
settings = {
state=true,
delay=1000,
posX=10,
posY=400
}
}, "GreenZoneChecker.ini")
local font = renderCreateFont("Verdana", 12, 5)
local tag = "{FFFF00}[GreenZoneChecker]:{FFFFFF} "
local gz = false
local moveRender = false
if not doesFileExist("moonloader/config/GreenZoneChecker.ini") then inicfg.save(mainIni, "GreenZoneChecker.ini") end
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("gz", function()
mainIni.settings.state = not mainIni.settings.state
inicfg.save(mainIni, "GreenZoneChecker.ini")
end)
sampRegisterChatCommand("gz.delay", setDelay)
sampRegisterChatCommand("gz.pos", function() moveRender = not moveRender end)
lua_thread.create(function()
while true do
wait(0)
if mainIni.settings.state then
renderFontDrawText(font, (gz and "{008000}Green Zone" or "{8B0000}No Green Zone"), mainIni.settings.posX, mainIni.settings.posY, -1)
end
if moveRender then
showCursor(true, true)
mainIni.settings.posX, mainIni.settings.posY = getCursorPos()
if wasKeyPressed(0x1) then
inicfg.save(mainIni, "GreenZoneChecker.ini")
showCursor(false, false)
moveRender = false
end
end
end
end)
while true do
wait(0)
if mainIni.settings.state then
if sampGetGamestate() == 3 and sampIsLocalPlayerSpawned() then
wait(mainIni.settings.delay)
sampSendChat("/gag")
end
end
end
end
function setDelay(arg)
if not tonumber(arg) then
sampAddChatMessage(tag.."Используйте: /gz.delay [number], текущая задержка: "..mainIni.settings.delay, -1)
else
mainIni.settings.delay = tonumber(arg)
sampAddChatMessage(tag.."Установлена задержка на "..mainIni.settings.delay, -1)
inicfg.save(mainIni, "GreenZoneChecker.ini")
end
end
function sampev.onServerMessage(color, text)
if mainIni.settings.state then
if text:find("Недоступно в Зеленой Зоне!") then
gz = true
return false
elseif text:find("Вы не состоите в мафии или в ФБР.") or text:find("В этом месте вы не можете применить данное действие!") or text:find("Команда доступна с (%d+)-го ранга.") or text:find("Используйте: /gag") then
gz = false
return false
end
end
end