require "lib.moonloader"
require "lib.samp.events"
local script_enabled = false
local is_task_active = false
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('autostrah', function()
script_enabled = not script_enabled
if script_enabled then
sampAddChatMessage("{00FF00}[AutoStrah]: Скрипт включен и ожидает заявлений.", -1)
else
sampAddChatMessage("{FF0000}[AutoStrah]: Скрипт выключен.", -1)
is_task_active = false
end
end)
sampAddChatMessage("[AutoStrah]: Скрипт загружен. Введите {00FF00}/autostrah{FFFFFF} для включения/выключения.", 0x8A2BE2)
wait(-1)
end
function samp.events.onServerMessage(color, text)
if not script_enabled then
return
end
if text:match("подал заявление на страхование имущества%.") and not is_task_active then
is_task_active = true
sampAddChatMessage("{FFFF00}[AutoStrah]: Обнаружено новое заявление. Принимаю...", -1)
lua_thread.create(function()
wait(math.random(300, 600))
setVirtualKeyDown(18, true)
wait(50)
setVirtualKeyDown(13, true)
wait(50)
setVirtualKeyDown(13, false)
wait(50)
setVirtualKeyDown(18, false)
end)
end
if text:match("Вы приняли заявление №%d+ на рассмотрение%.") then
if is_task_active then
is_task_active = false
sampAddChatMessage("{00FF00}[AutoStrah]: Заявление принято! Скрипт снова в режиме ожидания.", -1)
end
end
end