SlonPvpru

[DRP] LaniTheaft v1.0

Jun 17th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.95 KB | None | 0 0
  1. script_name('LaniTheft')
  2. script_version('1')
  3. script_properties('work-in-pause')
  4.  
  5. local script = 'lanitheft'
  6.  
  7. local data = {
  8.     ['breakcar']            = true;
  9.     ['active']              = true;
  10.     ['chat']                = true;
  11.     ['findugon']            = true;
  12.     ['ugon']                = true;
  13.     ['iszlata']             = true;
  14.     ['carslist']            = {};
  15.     ['markerslist']         = {}
  16. }
  17.  
  18. local as_action = require('moonloader').audiostream_state
  19. local memory = require 'memory'
  20. local ffi = require 'ffi'
  21. local sampev = require 'lib.samp.events'
  22. local dlstatus = require('moonloader').download_status
  23. --~ local limgui, imgui = pcall(require, 'imgui')
  24. local bNotf, notf = pcall(import, "lanisoft/imgui_notf.lua")
  25.  
  26. function main()
  27.     if not isSampLoaded() and not isSampfuncsLoaded() then return end
  28.     while not isSampAvailable() do wait(0) end
  29.  
  30.     --~     if not data['activation'] then checkactive() end
  31.  
  32.     if not doesDirectoryExist('moonloader/lanisoft') then createDirectory('moonloader/lanisoft') end
  33.     if not doesDirectoryExist('moonloader/lanisoft/sounds') then createDirectory('moonloader/lanisoft/sounds') end
  34.     if not doesFileExist('moonloader/lanisoft/imgui_notf.lua') then
  35.         wait(500)
  36.         download_id = downloadUrlToFile( 'https://lanisoft.ru/mysql/imgui_notf.lua', 'moonloader/lanisoft/imgui_notf.lua', download_handler)
  37.         wait(1500)
  38.         thisScript():reload()
  39.     end
  40.  
  41.     wait(200)
  42.  
  43.     getSoundStatus()
  44.  
  45.     while not musiccomplete do wait(0) end
  46.  
  47.     commandsRegistration()
  48.  
  49.     while true do wait(200)
  50.         while data['carslist'] == nil do wait(0) end
  51.         local vehicles = getAllVehicles()
  52.         for _, h in pairs(vehicles) do
  53.             local car = getCarModel(h)
  54.             if car then
  55.                 pedincar = getDriverOfCar(h)
  56.             end
  57.             if data['carslist'][car] and pedincar ~= playerPed then
  58.                 lua_thread.create(function()
  59.                     local _, carid = sampGetVehicleIdByCarHandle(h)
  60.                     local carplates = sampGetLicensePlateText(carid)
  61.                     if carplates == '-' or carplates:match('^([A-Z]%d%d%d[A-Z][A-Z])$') then
  62.                         data['carslist'][car] = false
  63.                         data['markerslist'][car] = addBlipForCar(h)
  64.                         changeBlipColour(data['markerslist'][car], 0x99FFCCBB)
  65.                         if not data['chat'] then
  66.                             MSG(1, 'Найден транспорт: ' .. objectCars[tostring(car)].name .. '\n\nНад транспортом поставлен маркер, на карте - метка. Введите /findcar чтобы убрать маркер/метку', 5, 'blat')
  67.                         elseif data['chat'] then
  68.                             MSG(1, 'Найден транспорт: ' .. objectCars[tostring(car)].name, 5, 'blat')
  69.                             MSG(2, 'Над транспортом поставлен маркер, на карте - метка. Введите /findcar чтобы убрать маркер/метку', 5, 'notif')
  70.                         end
  71.                         while data['carslist'][car] == false do wait(0)
  72.                             if isCharInAnyCar(PLAYER_PED) and storeCarCharIsInNoSave(PLAYER_PED) == h then
  73.                                 removeBlip(data['markerslist'][car])
  74.                                 data['markerslist'][car] = nil
  75.                                 while isCharInAnyCar(PLAYER_PED) do wait(0) end
  76.                                 data['carslist'][car] = true
  77.                             end
  78.                             if not doesVehicleExist(h) then
  79.                                 data['markerslist'][car] = nil
  80.                                 data['carslist'][car] = true
  81.                             end
  82.                         end
  83.                     end
  84.                 end)
  85.             end
  86.         end
  87.     end
  88. end
  89.  
  90. function commandsRegistration()
  91.     sampRegisterChatCommand(script, function()
  92.         if not data['active'] then checkactive()
  93.         elseif data['active'] then
  94.             MSG(2, 'Вы выключили ' ..thisScript().name, 5, 'kapec')
  95.             data['active'] = false
  96.         end
  97.     end)
  98.     sampRegisterChatCommand(script.. '_active', function(arg)
  99.         if not data['active'] then
  100.             theft_active(arg)
  101.         end
  102.     end)
  103.     sampRegisterChatCommand(script.. '_chat', function(arg)
  104.         if not data['active'] then MSG(3, 'Вы не авторизованы. Для активации скрипта введите \n/' ..script.. '_active <ключ>', 3, 'kapec') return end
  105.         data['chat'] = not data['chat']
  106.         MSG(2, 'Вы '..(data['chat'] and 'включили' or 'выключили')..' отображение сообщений в чате', 4, (data['chat'] and 'horosho' or 'ogo'))
  107.     end)
  108.     sampRegisterChatCommand('findcar', function(arg)
  109.         if not data['active'] then MSG(3, 'Вы не авторизованы. Для активации скрипта введите \n/' ..script.. '_active <ключ>', 3, 'kapec') return end
  110.         findcar(arg)
  111.     end)
  112.     sampRegisterChatCommand('findugon', function()
  113.         if not data['active'] then MSG(3, 'Вы не авторизованы. Для активации скрипта введите \n/' ..script.. '_active <ключ>', 3, 'kapec') return end
  114.         data['findugon'] = true
  115.         sampSendChat('/theft')
  116.     end)
  117.     sampRegisterChatCommand('ugon', function()
  118.         if not data['active'] then MSG(3, 'Вы не авторизованы. Для активации скрипта введите \n/' ..script.. '_active <ключ>', 3, 'kapec') return end
  119.         data['ugon'] = true
  120.         sampSendChat('/theft')
  121.     end)
  122.     sampRegisterChatCommand('breakcar', function()
  123.         if not data['active'] then MSG(3, 'Вы не авторизованы. Для активации скрипта введите \n/' ..script.. '_active <ключ>', 3, 'blat') return end
  124.         iscartut = false
  125.         isallcar = false
  126.         isarenda = false
  127.         lua_thread.create(function()
  128.             carhandle, _ = storeClosestEntities(playerPed)
  129.             for key, value in pairs(objectCars) do
  130.                 carplatesvalid = false
  131.                 modelid = key
  132.                 if carhandle ~= -1 and carhandle ~= nil and carhandle ~= '' then
  133.                     isallcar = true
  134.                     carresult = isCarModel(carhandle, modelid)
  135.                     if carresult == true then
  136.                         _resu, carid = sampGetVehicleIdByCarHandle(carhandle)
  137.                         carplates = sampGetLicensePlateText(carid)
  138.                         if carplates ~= '' and carplates ~= nil then
  139.                             if carplates:match('^[A-Z]%d%d%d[A-Z][A-Z]$') then
  140.                                 carplatesvalid = true
  141.                             end
  142.                         end
  143.                         if carplates ~= '' and carplates ~= nil and carplatesvalid and carplatesvalid ~= nil then
  144.                             carplatesvalid = true
  145.                             x1, y1, z1 = getCharCoordinates(playerPed)
  146.                             x2, y2, z2 = getCarCoordinates(carhandle)
  147.                             distance = getDistanceBetweenCoords3d(x1, y1, z1, x2, y2, z2)
  148.                             carname = value.name
  149.                             iscartut = true
  150.                             if distance < 3 then
  151.                                 data['breakcar'] = true
  152.                                 breakcarid = key
  153.                                 sampSendChat('/device')
  154.                             else
  155.                                 if not data['chat'] then
  156.                                     MSG(3, 'Вы находитесь слишком далеко от \n' ..carname, 3, 'kapec')
  157.                                 elseif data['chat'] then
  158.                                     MSG(3, 'Вы находитесь слишком далеко от ' ..carname, 3, 'kapec')
  159.                                 end
  160.                             end
  161.                         elseif carplates ~= '' and carplates ~= nil and carplates == '-' then
  162.                             carplatesvalid = true
  163.                             x1, y1, z1 = getCharCoordinates(playerPed)
  164.                             x2, y2, z2 = getCarCoordinates(carhandle)
  165.                             distance = getDistanceBetweenCoords3d(x1, y1, z1, x2, y2, z2)
  166.                             carname = value.name
  167.                             iscartut = true
  168.                             if distance < 3 then
  169.                                 data['breakcar'] = true
  170.                                 breakcarid = key
  171.                                 sampSendChat('/device')
  172.                             else
  173.                                 MSG(3, 'Вы находитесь слишком далеко от ' ..carname, 3, 'kapec')
  174.                             end
  175.                         elseif not carplatesvalid then
  176.                             MSG(3, 'Взлому подлежат только личные транспортные средства', 3, 'kapec')
  177.                             isarenda = true
  178.                         end
  179.                     end
  180.                 end
  181.             end
  182.             if not carplatesvalid then
  183.                 carisnotvalid = true
  184.             end
  185.             if not iscartut and carisnotvalid and isallcar and not isarenda then
  186.                 MSG(3, 'Это транспортное средство не подлежит взлому', 3, 'kapec')
  187.                 carisnotvalid = false
  188.             end
  189.             if not isallcar then
  190.                 MSG(3, 'Рядом с Вами нет транспорта', 3, 'kapec')
  191.             end
  192.         end)
  193.     end)
  194. end
  195. --------------------------------------------------------------------------------------------------------------------------------------------
  196. function findcar(arg)
  197.     local arg = arg:match('%s*(.+)')
  198.     if arg ~= nil then
  199.         data["carslist"] = {}
  200.         for a, b in pairs(data["markerslist"]) do
  201.             removeBlip(b)
  202.         end
  203.         data["markerslist"] = {}
  204.         for line in arg:gmatch("[^%|]+") do
  205.             if tonumber(line) ~= nil then
  206.                 local line = tonumber(line)
  207.                 if line >= 400 and line <= 611 then
  208.                     if objectCars[tostring(line)] ~= nil then
  209.                         table.insert(data["carslist"], line, true)
  210.                     else
  211.                         MSG(3, 'Транспорт ' ..line.. ' нельзя взломать, либо Вы неверно указали его название.', 3, 'kapec')
  212.                     end
  213.                 else
  214.                     MSG(3, 'ID транспорта не может быть меньше 400 и больше 611. Вы ввели: '.. line, 3, 'kapec')
  215.                 end
  216.             else
  217.                 for i = 400, 612 do
  218.                     if i == 612 then MSG(3, 'Транспорт ' ..line.. ' нельзя взломать, либо Вы неверно указали его название.', 3, 'kapec') break end
  219.                     if objectCars[tostring(i)] ~= nil then
  220.                         if string.lower(objectCars[tostring(i)].name):find(string.lower(line)) then
  221.                             table.insert(data["carslist"], i, true)
  222.                             break
  223.                         end
  224.                     end
  225.                 end
  226.             end
  227.         end
  228.         local carscount = 0
  229.         for a, b in pairs(data["carslist"]) do
  230.             carscount = carscount + 1
  231.         end
  232.         if carscount == 1 then
  233.             for a, b in pairs(data["carslist"]) do
  234.                 local thiscarname = objectCars[tostring(a)].name
  235.                 MSG(2, 'Активирован поиск транспорта ' .. thiscarname .. '\n\nДля отключения поиска введите /findcar', 5, 'horosho')
  236.             end
  237.         elseif carscount > 1 then
  238.             local lcarslist = ''
  239.             for a, b in pairs(data["carslist"]) do
  240.                 lcarslist = objectCars[tostring(a)].name..', '.. lcarslist
  241.             end
  242.             MSG(2, 'Активирован поиск следующих транспортных средств:\n' .. lcarslist:match('(.*), $') .. '.\n\nДля отключения поиска введите /findcar', 5, 'horosho')
  243.         end
  244.     else
  245.         local carscount = 0
  246.         for a, b in pairs(data["carslist"]) do
  247.             carscount = carscount + 1
  248.         end
  249.         if carscount == 0 then
  250.             if data["chat"] then
  251.                 MSG(3, 'Используйте {cccccc}/findcar <ID/Название>', 5, 'kapec')
  252.             elseif not data["chat"] then
  253.                 MSG(3, 'Используйте /findcar <ID/Название>', 3, 'kapec')
  254.             end
  255.         else
  256.             data["carslist"] = {}
  257.             for a, b in pairs(data["markerslist"]) do
  258.                 removeBlip(b)
  259.             end
  260.             data["markerslist"] = {}
  261.             MSG(2, 'Поиск отменён', 3, 'kapec')
  262.         end
  263.     end
  264. end
  265.  
  266. function getSoundStatus()
  267.     local soundlist = {
  268.         'ban',
  269.         'blat',
  270.         'horosho',
  271.         'kapec',
  272.         'ogo',
  273.         'siren',
  274.         'notif'
  275.     }
  276.  
  277.     for a, b in pairs(soundlist) do
  278.         if not doesFileExist('moonloader/lanisoft/sounds/'.. b ..'.mp3') then
  279.             sampAddChatMessage('• {00CC00}[Успешно] {ffffff}Загружаю необходимые звуки', -1)
  280.             download_id = downloadUrlToFile( 'https://lanisoft.ru/mysql/' .. soundlist[1] .. '.mp3',  'moonloader/lanisoft/sounds/'.. soundlist[1] ..'.mp3', download_handler)
  281.             download_id = downloadUrlToFile( 'https://lanisoft.ru/mysql/' .. soundlist[2] .. '.mp3',  'moonloader/lanisoft/sounds/'.. soundlist[2] ..'.mp3', download_handler)
  282.             download_id = downloadUrlToFile( 'https://lanisoft.ru/mysql/' .. soundlist[3] .. '.mp3',  'moonloader/lanisoft/sounds/'.. soundlist[3] ..'.mp3', download_handler)
  283.             download_id = downloadUrlToFile( 'https://lanisoft.ru/mysql/' .. soundlist[4] .. '.mp3',  'moonloader/lanisoft/sounds/'.. soundlist[4] ..'.mp3', download_handler)
  284.             download_id = downloadUrlToFile( 'https://lanisoft.ru/mysql/' .. soundlist[5] .. '.mp3',  'moonloader/lanisoft/sounds/'.. soundlist[5] ..'.mp3', download_handler)
  285.             download_id = downloadUrlToFile( 'https://lanisoft.ru/mysql/' .. soundlist[6] .. '.mp3',  'moonloader/lanisoft/sounds/'.. soundlist[6] ..'.mp3', download_handler)
  286.             download_id = downloadUrlToFile( 'https://lanisoft.ru/mysql/' .. soundlist[7] .. '.mp3',  'moonloader/lanisoft/sounds/'.. soundlist[7] ..'.mp3', download_handler)
  287.             break
  288.         end
  289.     end
  290.  
  291.     musiccomplete = true
  292. end
  293.  
  294. function download_handler(id, status, p1, p2)
  295.     if stop_downloading then
  296.         stop_downloading = false
  297.         download_id = nil
  298.         print('Загрузка отменена.')
  299.         return false -- прервать загрузку
  300.     end
  301.     if p1 > 1 and p2 == 0 then
  302.         print("Превышено время ожидания конца загрузки.")
  303.     elseif status == dlstatus.STATUS_DOWNLOADINGDATA then
  304.         print(string.format('Загружено %d КБ из %d КБ.', p1, p2))
  305.     elseif status == dlstatus.STATUS_ENDDOWNLOADDATA then
  306.         print('Загрузка файла завершена.')
  307.     end
  308. end
  309.  
  310. function theft_active(arg)
  311.     arg = arg:match('%s*(.+)')
  312.     if arg ~= '' and arg ~= nil then
  313.         math.randomseed(os.time())
  314.         local fpath = math.random(50, 256) ^ 2
  315.         ip, port = sampGetCurrentServerAddress()
  316.         local surl = http_build_query({server = ip, win = getSerialNumber(), proc = getProcessorName(), script = script, pass = arg})
  317.         downloadUrlToFile('https://lanisoft.ru/mysql/addaccess.php?'.. surl, os.getenv('TEMP') .. '\\'.. fpath ..'.txt', function(id, status, p1, p2) lua_thread.create(function()
  318.             if status == dlstatus.STATUS_ENDDOWNLOADDATA then
  319.                 wait(50)
  320.                 local win = getSerialNumber()
  321.                 local f = io.open(os.getenv('TEMP') .. '\\'.. fpath ..'.txt', 'r')
  322.                 result = f:read('*a')
  323.                 if result then
  324.                     if result == 'error' then
  325.                         MSG(3, 'Ключ ' ..arg .. ' не существует', 3, 'blat')
  326.                     elseif result == 'okey' then
  327.                         MSG(1, 'Вы активировали ' ..thisScript().name, 3, 'blat')
  328.                         checkactive()
  329.                     elseif result == 'errorkey' then
  330.                         MSG(3, 'Ключ ' ..arg .. ' не существует', 3, 'blat')
  331.                     end
  332.                     f:close()
  333.                 else
  334.                     MSG(2, 'Произошла ошибка.', 3, 'blat')
  335.                 end
  336.                 os.remove(fpath)
  337.             end
  338.         end)
  339.         end)
  340.     end
  341. end
  342. --------------------------------------------------------------------------------------------------------------------------------------------
  343. function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
  344.     if data['ugon'] then
  345.         if title:find('Угон автомобилей$') then
  346.             data['ugon'] = false
  347.             carstring = 'Текущий транспорт:\n'
  348.             for linetext in text:gmatch('[^\r\n]+') do
  349.                 carexist = 0
  350.                 if not linetext:find('Расположение') then
  351.                     theftcarname, theftcartime1, theftcartime2 = linetext:match('(.*)%s+(%d+)%:(%d+).*')
  352.                     theftcartime = theftcartime1.. ':' ..theftcartime2
  353.                     for key, value in pairs(objectCars) do
  354.                         if value.name == theftcarname then
  355.                             theftcarmodelid = key
  356.                             theftcarprice = tonumber(value.price)
  357.                             theftcarclass = tonumber(value.class)
  358.                             if theftcarclass == 1 then
  359.                                 rate = 5000
  360.                                 percent = 0.025
  361.                                 carclass = 'Эконом класс'
  362.                             elseif theftcarclass == 2 then
  363.                                 rate = 25000
  364.                                 percent = 0.0125
  365.                                 carclass = 'Средний класс'
  366.                             elseif theftcarclass == 3 then
  367.                                 rate = 50000
  368.                                 percent = 0.005
  369.                                 carclass = 'Спорт класс'
  370.                             elseif theftcarclass == 4 then
  371.                                 rate = 50000
  372.                                 percent = 0.005
  373.                                 carclass = 'Мотоцикл'
  374.                             end
  375.                             money = rate + (theftcarprice * percent)
  376.                             money = math.floor(money)
  377.                             carstring = carstring.. '\n' ..carclass.. ' • ' ..theftcarname.. '\nВремя: ' ..theftcartime.. '\nГос. цена: ' ..theftcarprice.. '$\nНаграда: ' ..money.. '$\n'
  378.                             if data['chat'] then
  379.                                 MSG(2, carclass.. ' • ' ..theftcarname.. ' • Время: ' ..theftcartime.. ' • Гос. цена: ' ..theftcarprice.. '$ • Награда: ' ..money.. '$', 8, 'blat')
  380.                             end
  381.                         end
  382.                     end
  383.                 end
  384.             end
  385.             if not data['chat'] then
  386.                 MSG(2, carstring, 8, 'blat')
  387.             end
  388.             sampSendDialogResponse(dialogId, 1, 0, '')
  389.             return false
  390.         end
  391.     end
  392.     if data['findugon'] then
  393.         if title:find('Угон автомобилей$') then
  394.             local c2list = {}
  395.             for linetext in text:gmatch('[^\r\n]+') do
  396.                 if not linetext:find('Расположение') then
  397.                     local theftcarname, theftcartime1, theftcartime2 = linetext:match('(.*)%s+(%d+)%:(%d+).*')
  398.                     for i = 400, 612 do
  399.                         if i == 612 then MSG(3, 'Транспорт ' ..theftcarname.. ' нельзя взломать.', 3, 'kapec') break end
  400.                         if objectCars[tostring(i)] ~= nil then
  401.                             if string.lower(objectCars[tostring(i)].name) == string.lower(theftcarname) then
  402.                                 table.insert(data['carslist'], i, true)
  403.                                 table.insert(c2list, i)
  404.                                 break
  405.                             end
  406.                         end
  407.                     end
  408.                 end
  409.             end
  410.             local carltext = ''
  411.             for _, h in pairs(c2list) do
  412.                 carltext = objectCars[tostring(h)].name.. ', '.. carltext
  413.             end
  414.             if not data['chat'] then
  415.                 MSG(2, 'Активирован поиск транспорта:\n' ..carltext:match('(.*), $') .. '.\n\nДля отключения поиска введите /findcar', 5, 'horosho')
  416.             elseif data['chat'] then
  417.                 MSG(2, 'Активирован поиск транспорта. ' ..carltext:match('(.*), $') .. '.\n\nДля отключения поиска введите /findcar', 5, 'horosho')
  418.                 MSG(2, ' {ffc900}• {ffffff}' ..carltext:match('(.*), $'), 5, 'horosho')
  419.                 MSG(2, 'Для отключения поиска введите /findcar', 5, 'horosho')
  420.             end
  421.             sampSendDialogResponse(dialogId, 1, 0, nil)
  422.             data['findugon'] = false
  423.             return false
  424.         end
  425.     end
  426.     if data['breakcar'] then
  427.         if title:find('Оборудование$') then
  428.             linenum = -1
  429.             drillishere = 0
  430.             for linetext in text:gmatch('[^\r\n]+') do
  431.                 linenum = linenum + 1
  432.                 if linetext:find('Дрель') then
  433.                     drillishere = 1
  434.                     sampSendDialogResponse(dialogId, 1, linenum, '')
  435.                 end
  436.             end
  437.             if drillishere == 0 then
  438.                 MSG(3, 'У Вас нет инструмента Дрель. Приобретите его в магазине радиоигрушек.', 5, 'kapec')
  439.             end
  440.             return false
  441.         end
  442.     end
  443. end
  444.  
  445. function sampev.onShowTextDraw(idtd, infotd)
  446.     if data['breakcar'] then
  447.         if infotd.text == 'Drilling the door' and objectCars ~= nil then drilltdid = idtd lua_thread.create(clickalltd) end
  448.     end
  449. end
  450.  
  451. function clickalltd()
  452.     if data['breakcar'] then
  453.         data['breakcar'] = false
  454.         wait(200)
  455.         local drillcount = drilltdid + 65
  456.         MSG(2, 'Начинаем процесс взлома ' ..carname, 3, 'blat')
  457.         for key, value in pairs(objectCars[breakcarid].scheme) do
  458.             for i = 1, value do
  459.                 sampSendClickTextdraw(drillcount)
  460.                 wait(10)
  461.             end
  462.             drillcount = drillcount + 2
  463.         end
  464.         drilling = drilltdid + 4
  465.         sampSendClickTextdraw(drilling)
  466.     end
  467. end
  468.  
  469. function checkactive()
  470.     math.randomseed(os.time())
  471.     local fpath = math.random(50, 256) ^ 2
  472.     local fpath = os.getenv('TEMP') .. '\\'.. fpath ..'.txt'
  473.     local ip = sampGetCurrentServerAddress()
  474.     local surl = http_build_query({server = ip, win = getSerialNumber(), proc = getProcessorName(), script = script})
  475.     downloadUrlToFile('https://lanisoft.ru/mysql/checkaccess.php?'.. surl, fpath, function(id, status, p1, p2) lua_thread.create(function()
  476.         if status == dlstatus.STATUS_ENDDOWNLOADDATA then
  477.             wait(50)
  478.             local f = io.open(fpath, 'r')
  479.             if f then
  480.                 local result = f:read('*a')
  481.                 if result == 'error' then
  482.                     MSG(3, 'Вы не были авторизованы в ' ..thisScript().name, 3, 'kapec')
  483.                     data['active'] = false
  484.                 elseif result:find('Bullet') then
  485.                     MSG(1, 'Вы были авторизованы в ' ..thisScript().name, 3, 'ban')
  486.                     data['active'] = true
  487.                     objectCars = decodeJson(result)
  488.                     lua_thread.create(checkbuild)
  489.                 else
  490.                     MSG(3, 'Произошла ошибка', 3, 'kapec')
  491.                     data['active'] = false
  492.                 end
  493.                 f:close()
  494.             else
  495.                 MSG(2, 'Произошла ошибка', 3, 'kapec')
  496.                 data['active'] = false
  497.             end
  498.             os.remove(fpath)
  499.         end
  500.     end)
  501.     end)
  502. end
  503.  
  504. function checkbuild()
  505.     math.randomseed(os.time())
  506.     local fpath = math.random(50, 256) ^ 2
  507.     local fpath = os.getenv('TEMP') .. '\\'.. fpath ..'.txt'
  508.     local surl = http_build_query({script = script})
  509.     downloadUrlToFile('https://lanisoft.ru/mysql/checkbuild.php?' ..surl, fpath, function(id, status, p1, p2) lua_thread.create(function()
  510.         if status == dlstatus.STATUS_ENDDOWNLOADDATA then
  511.             wait(50)
  512.             local f = io.open(fpath, 'r')
  513.             result = f:read('*a')
  514.             if result then
  515.                 if tonumber(thisScript().version) > tonumber(result) then
  516.                     MSG(2, 'Вы используете тестовую версию ' ..thisScript().name, 3, 'notif')
  517.                 elseif tonumber(thisScript().version) == tonumber(result) then
  518.                     MSG(2, 'Вы используете актуальную версию ' ..thisScript().name, 3, 'notif')
  519.                 elseif tonumber(thisScript().version) < tonumber(result) then
  520.                     MSG(2, 'Найдено обновление. Загружаем...', 3, 'blat')
  521.                     downloadUrlToFile('https://lanisoft.ru/softs/' ..script.. '.luac', thisScript().path, function(id, status, p1, p2)
  522.                         if status == dlstatus.STATUS_ENDDOWNLOADDATA then
  523.                             os.remove(fpath)
  524.                             MSG(1, 'Загрузка обновления ' ..thisScript().name.. ' {ffffff}завершена', 3, 'notif')
  525.                             thisScript():reload()
  526.                         end
  527.                     end)
  528.                 end
  529.             else
  530.                 MSG(2, 'При проверке обновлений возникла ошибка', 3, 'kapec')
  531.             end
  532.             os.remove(fpath)
  533.         end
  534.     end)
  535.     end)
  536. end
  537.  
  538. function MSG(typetext, text, sec, typemsg)
  539.     lua_thread.create(function()
  540.         if not data['chat'] and bNotf then
  541.             notf.addNotification(thisScript().name.. '\n\n' ..text, sec, typetext)
  542.             Audio = loadAudioStream("moonloader/lanisoft/sounds/" ..typemsg.. ".mp3")
  543.             setAudioStreamVolume(Audio, 100)
  544.             if data['iszlata'] then
  545.                 data['iszlata'] = false
  546.                 setAudioStreamState(Audio, as_action.PLAY)
  547.                 wait(2000)
  548.                 data['iszlata'] = true
  549.             end
  550.         elseif data['chat'] then
  551.             if typetext == 1 then
  552.                 prefix = '• {00CC00}[Успешно] {ffffff}'
  553.             end
  554.             if typetext == 3 then
  555.                 prefix = '• {AC0000}[Ошибка] {FFFFFF}'
  556.             end
  557.             if typetext == 2 then
  558.                 prefix = '• {FFC800}[LaniTheft] {ffffff}'
  559.             end
  560.             text = string.gsub(text, '\n\n', '\n')
  561.             text = string.gsub(text, '\n', '. ')
  562.             sampAddChatMessage(prefix.. '' ..text, -1)
  563.             Audio = loadAudioStream("moonloader/lanisoft/sounds/" ..typemsg.. ".mp3")
  564.             setAudioStreamVolume(Audio, 100)
  565.             if data['iszlata'] then
  566.                 data['iszlata'] = false
  567.                 setAudioStreamState(Audio, as_action.PLAY)
  568.                 wait(2000)
  569.                 data['iszlata'] = true
  570.             end
  571.         end
  572.     end)
  573. end
  574. --------------------------------------------------------------------------------------------------------------------------------------------
  575. function http_build_query(query)
  576.     local function char_to_hex(str)
  577.         return string.format("%%%02X", string.byte(str))
  578.     end
  579.  
  580.     local function url_encode(str)
  581.         local str = string.gsub(str, "\\", "\\")
  582.         local str = string.gsub(str, "([^%w])", char_to_hex)
  583.         return str
  584.     end
  585.  
  586.     local buff=""
  587.     for k, v in pairs(query) do
  588.         buff = buff.. string.format("%s=%s&", k, url_encode(v))
  589.     end
  590.     local buff = string.reverse(string.gsub(string.reverse(buff), "&", "", 1))
  591.     return buff
  592. end
  593.  
  594. function getProcessorName_code(n)
  595.     local ffi = require("ffi")
  596.     local qwords = ffi.typeof("uint64_t[?]")
  597.     local dwords = ffi.typeof("uint32_t *")
  598.     local cpuid_EAX_EDX = ffi.cast("__cdecl uint64_t (*)(uint32_t)", "\x53\x0F\xA2\x5B\xC3")
  599.     local cpuid_EBX_ECX = ffi.cast("__cdecl uint64_t (*)(uint32_t)", "\x53\x0F\xA2\x91\x92\x93\x5B\xC3")
  600.  
  601.     local arr = ffi.cast(dwords, qwords(2, cpuid_EAX_EDX(n), cpuid_EBX_ECX(n)))
  602.     return ffi.string(arr, 4), ffi.string(arr + 2, 4), ffi.string(arr + 3, 4), ffi.string(arr + 1, 4)
  603. end
  604.  
  605. function getProcessorName()
  606.     local s1 = ""
  607.     for n = 0x80000002, 0x80000004 do
  608.         local eax, ebx, ecx, edx = getProcessorName_code(n)
  609.         s1 = s1..eax..ebx..ecx..edx
  610.     end
  611.     s1 = s1:gsub("^%s+", ""):gsub("%z+$", "")
  612.  
  613.     return s1
  614. end
  615.  
  616. function getSerialNumber()
  617.     local ffi = require("ffi")
  618.     ffi.cdef
  619.         [[
  620.  
  621. int __stdcall GetVolumeInformationA(
  622.         const char* lpRootPathName,
  623.         char* lpVolumeNameBuffer,
  624.         uint32_t nVolumeNameSize,
  625.         uint32_t* lpVolumeSerialNumber,
  626.         uint32_t* lpMaximumComponentLength,
  627.         uint32_t* lpFileSystemFlags,
  628.         char* lpFileSystemNameBuffer,
  629.         uint32_t nFileSystemNameSize
  630.     );
  631. ]]
  632.  
  633.     local serial = ffi.new("unsigned long[1]", 0)
  634.     ffi.C.GetVolumeInformationA("c:\\", nil, 0, serial, nil, nil, nil, 0)
  635.  
  636.     return serial[0]
  637. end
  638.  
  639. function sampSetLicensePlateText(id, text)
  640.     local vehpool = sampGetVehiclePoolPtr()
  641.     if memory.getuint8(vehpool + 0x3074 + id * 4) == 1 then
  642.         local this = ffi.cast('void*', memory.getuint32(vehpool + 0x1134 + id * 4))
  643.         ffi.cast('void(__thiscall*)(void*this, const char* text)', sampGetBase() + 0xB1BF0)(this, ffi.cast('char*', text))
  644.     end
  645. end
  646.  
  647. function sampGetLicensePlateText(id)
  648.     local vehpool = sampGetVehiclePoolPtr()
  649.     if memory.getuint8(vehpool + 0x3074 + id * 4) == 1 then
  650.         local this = memory.getuint32(vehpool + 0x1134 + id * 4)
  651.         return memory.tostring(this + 0x93)
  652.     end
  653. end
  654.  
  655. function onScriptTerminate(script)
  656.     if script == thisScript() then
  657.         for a, b in pairs(data['markerslist']) do
  658.             removeBlip(b)
  659.         end
  660.     end
  661. end
Add Comment
Please, Sign In to add comment