script_name("Auto Cars Unload for ARZ")
script_author("YarikVL")
local memory, se = require 'memory', require 'samp.events'
local CarsUnload, forUnload, count = true, {}, {false, false, false}
function main()
while not isSampAvailable() do wait(0) end
local module = getModuleHandle("SAMPFUNCS.asi")
if module ~= 0 and memory.compare(module + 0xBABD, memory.strptr('\x8B\x43\x04\x8B\x5C\x24\x20\x8B\x48\x34\x83\xE1'), 12) then
memory.setuint16(module + 0x83349, 0x01ac, true)
memory.setuint16(module + 0x8343c, 0x01b0, true)
memory.setuint16(module + 0x866dd, 0x00f4, true)
memory.setuint16(module + 0x866e9, 0x0306, true)
memory.setuint8(module + 0x8e754, 0x40, true)
end
while not sampIsLocalPlayerSpawned() do wait(500) end
sampSendChat('/cars'); wait(-1)
end
function se.onSendCommand(cmd)
if cmd == '/cunl' then
sampSendChat('/cars'); CarsUnload = true
return false
end
end
function se.onShowDialog(id, style, title, button1, button2, text)
if id == 162 or id == 163 and (count[1] and not count[2]) or (not count[1] and count[2]) or (count[1] and count[2]) then
sampSendDialogResponse(id, 1, id == 163 and 11 or 0, nil); count[1], count[2] = false, false
return false
elseif count[3] and id == 162 then
sampCloseCurrentDialogWithButton(0); count[3] = false
return false
end
if CarsUnload and title:find("Мой транспорт") then
forUnload = {}
local line = -1
for v in string.gmatch(text, '[^\n]+') do
line = line + 1
if v:find('%[Не припарковано%]') or v:find('%[Штрафстоянка%]') then
table.insert(forUnload, line)
end
end
if #forUnload > 0 then
for i = 1, #forUnload do
local lline = forUnload[i]
if lline == 0 then
count[1] = true
elseif lline == 1 then
count[2] = true
end
end
else
sampAddChatMessage("У вас нету транспортных средств которые находились бы на штрафстоянке или были не припаркованы", 0x00FF00)
count[3] = true
end; CarsUnload = false
end
end