require 'lib.moonloader'
local sampev = require 'samp.events'
local t = {}
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("autounloadtruck", function()
active = not active
printStringNow(active and "Auto Unload Truck ON" or "Auto Unload Truck OFF")
end)
while true do wait(0)
if active and #t > 0 and sampIsDialogActive()
for i = 1, #t do
lline = t[i]
sampSendDialogResponse(sampGetCurrentDialogId(), 1, lline, nil)
wait(150)
sampSendDialogResponse(sampGetCurrentDialogId(), 1, 11, nil)
end
end
end
function sampev.onServerMessage(color, text)
lua_thread.create(function()
if text:find('Ваш автомобиль был взорван') and not text:find("говорит") then
if not sampIsCursorActive() then
sampSendChat("/cars")
repeat wait(0) until sampIsDialogActive()
local line = -1
for v in string.gmatch(text, '[^\r\n]+') do
if text:find("ТОЧНОЕ НАЗВАНИЕ ТВОЕЙ ФУРЫ") and not text:find("Не загружено") then
line = line + 1
table.insert(t, line)
end
end
else
repeat wait(0) until not sampIsCursorActive()
sampSendChat("/cars")
repeat wait(0) until sampIsDialogActive()
local line = -1
for v in string.gmatch(text, '[^\r\n]+') do
if text:find("ТОЧНОЕ НАЗВАНИЕ ТВОЕЙ ФУРЫ") and not text:find("Не загружено") then
line = line + 1
table.insert(t, line)
end
end
end)
end