SlonPvpru

[DRP] Fruit-Bot v1.0.5

Jun 6th, 2020
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 29.19 KB | None | 0 0
  1. -- https://www.blast.hk/threads/56791/
  2.  
  3. script_version("1.0.4")
  4. require "lib.sampfuncs"
  5. require "lib.moonloader"
  6. script_properties("work-in-pause")
  7. local sampev = require 'lib.samp.events'
  8. local encoding = require 'encoding'
  9. local inicfg = require 'inicfg'
  10. encoding.default = 'CP1251'
  11. u8 = encoding.UTF8
  12. local imgui = require 'imgui'
  13. local vkeys = require 'vkeys'
  14. local memory = require "memory"
  15. local ip = 'ws://45.140.167.12:27801'
  16. local websocket = ''
  17. local client =''
  18. websocket = require 'websocket'
  19. client = websocket.client.copas({timeout = 2})
  20. local ffi = require("ffi")
  21. ffi.cdef[[
  22. int __stdcall GetVolumeInformationA(
  23.     const char* lpRootPathName,
  24.     char* lpVolumeNameBuffer,
  25.     uint32_t nVolumeNameSize,
  26.     uint32_t* lpVolumeSerialNumber,
  27.     uint32_t* lpMaximumComponentLength,
  28.     uint32_t* lpFileSystemFlags,
  29.     char* lpFileSystemNameBuffer,
  30.     uint32_t nFileSystemNameSize
  31. );
  32. ]]
  33. local serial = ffi.new("unsigned long[1]", 0)
  34. ffi.C.GetVolumeInformationA(nil, nil, 0, serial, nil, nil, nil, 0)
  35. serial = serial[0]
  36. local fa = require 'fAwesome5'
  37. imgui.ToggleButton = require('imgui_addons').ToggleButton
  38. local fa_font = nil
  39. local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
  40. local cord = {}
  41. local random_place = {}
  42. local movestatus = false
  43. local gopress = false
  44. local status = false
  45. local txd_time = false
  46. local txd_close_id = -1
  47. local txd_applecount = 0
  48. local current_tree = -1
  49. local last_apple = {}
  50. local home_cord = {}
  51. local treecord = {}
  52. local post_reise = 0
  53. local pause = false
  54. local fruit_model = {}
  55. local txd_status = false
  56. local mouse_state = false
  57. local iScreenWidth, iScreenHeight = getScreenResolution()
  58. ------------------IMGUI--------------------
  59. local imgui_window_hud = imgui.ImBool(false)
  60. local imgui_window_menu = imgui.ImBool(false)
  61. local select_button = 1
  62. ------------------IMGUI--------------------
  63.  
  64.  
  65.  
  66. -----------------CONFIG--------------------
  67. local inicfg = require 'inicfg'
  68. if not doesFileExist('moonloader\\config\\FruitBot\\FruitBot.ini') then
  69. if not doesDirectoryExist('moonloader\\config\\FruitBot') then
  70.         createDirectory('moonloader\\config\\FruitBot')
  71. end
  72.     local  ini =
  73.         {
  74.                 config =
  75.                 {
  76.                     aafk = false,
  77.                     sun_trees = false,
  78.                     remove_trees = false,
  79.                     manual_mode = false,
  80.                     vk_send_admin = true,
  81.                     vk_send_report = true,
  82.                     cfg_hud = true,
  83.                     mode = 'Apple'
  84.  
  85.                 }
  86.         }
  87.         inicfg.save(ini, 'FruitBot\\FruitBot')
  88. end
  89. local directIni = 'moonloader\\config\\FruitBot\\FruitBot.ini'
  90. local mainIni = inicfg.load(nil, directIni)
  91. local cfg_remove_trees = imgui.ImBool((mainIni.config.cfg_remove_trees==true))
  92. local cfg_aafk = imgui.ImBool((mainIni.config.cfg_aafk==true))
  93. local cfg_sun_trees = imgui.ImBool((mainIni.config.cfg_sun_trees==true))
  94. local cfg_int_maxreise = imgui.ImInt((mainIni.config.cfg_int_maxreise and mainIni.config.cfg_int_maxreise or 10))
  95. local cfg_manual_mode = imgui.ImBool((mainIni.config.cfg_manual_mode == true))
  96. local cfg_vk_send_report = imgui.ImBool((mainIni.config.cfg_vk_send_report == true))
  97. local cfg_vk_send_admin = imgui.ImBool((mainIni.config.cfg_vk_send_admin == true))
  98. local cfg_hud = imgui.ImBool((mainIni.config.cfg_hud == true))
  99. local vk_send_cd = imgui.ImBool((mainIni.config.vk_send_cd == true))
  100. local vk_int_send_cd = imgui.ImInt((mainIni.config.vk_int_send_cd and mainIni.config.vk_int_send_cd or 5))
  101. local cfg_eat_msg = imgui.ImBool((mainIni.config.cfg_eat_msg == true))
  102. local mode = mainIni.config.mode
  103. -----------------CONFIG--------------------
  104. local bool_random = {true,false}
  105. ------------------STATS--------------------
  106. local stats = {
  107.     money = 0,
  108.     reise = 0,
  109.     apple = 0,
  110.     status = 'Ожидание...'
  111. }
  112. --------- 46---------STATS--------------------
  113.  
  114. function main()
  115.     repeat wait(0) until isSampAvailable()
  116.     autoupdate("No links", '['..string.upper(thisScript().name)..']: ', "No links")
  117.     aafk(cfg_aafk.v)
  118.     _, my_id =  sampGetPlayerIdByCharHandle(PLAYER_PED)
  119.     user =  sampGetPlayerNickname(my_id)
  120.     local connected, err = client:connect(ip, '')
  121.     if err then print(err) end
  122.     if connected then
  123.         if not connected then
  124.             sampAddChatMessage('{B40431}[F-BOOM]{ffffff} - Ошибка соединения с сервером.',-1)
  125.         else
  126.             sampAddChatMessage('{5858FA}[F-BOOM]{ffffff} - Вы успешно подключились к серверу скрипта, ожидание авторизации...',-1)
  127.             local server,port =  sampGetCurrentServerAddress()
  128.             _, my_id =  sampGetPlayerIdByCharHandle(PLAYER_PED)
  129.             user =  sampGetPlayerNickname(my_id)
  130.             client:send(encodeJson({
  131.                                                              soft='fbot',
  132.                                                              action = 'auth',
  133.                                                              serial = tostring(serial),
  134.                                                              user = user,
  135.                                                              server = tostring(server)
  136.                                                          }))
  137.         end
  138.     end
  139.     sampRegisterChatCommand('zfb', function() imgui_window_menu.v = not imgui_window_menu.v end)
  140.     sampRegisterChatCommand('apl', function() lua_thread.create(function() getfruit() end) end)
  141.     sampRegisterChatCommand('copymycode', function() setClipboardText(serial);sampAddChatMessage('Ваш персональный код скопирован в буфер обмена', -1) end)
  142.     sampRegisterChatCommand('cop',function()
  143.         local x,y,z = getCharCoordinates(playerPed)
  144.         setClipboardText("['x'=>"..x..",'y'=>"..y..",'z'=>"..z..'],')
  145.     end)
  146.     lua_thread.create(function()
  147.         while true do wait(0)
  148.             local message, opcode = client:receive()
  149.             if message then
  150.                 local result = decodeJson(message)
  151.                 if result['action'] == 'auth' then
  152.                     cord = result['cord']
  153.                     random_place = result['random_cord']
  154.                     home_cord = result['home_cord']
  155.                     fruit_model = result ['fruit_model']
  156.                     sampAddChatMessage('{E9967A}[F-BOT]{ffffff} - Успешная авторизация, данные о лицензии подтверждены!', -1)
  157.                     sampAddChatMessage('{E9967A}[F-BOT]{ffffff} - Осталось {E9967A}'..result['days']..'{ffffff} дней лицензии',-1)
  158.                     sampAddChatMessage('{E9967A}[F-BOT]{ffffff} - Меню бота: {E9967A}/zfb',-1)
  159.                 elseif result['action'] == 'error' then
  160.                     sampAddChatMessage('{E9967A}[F-BOT] - {ffffff}'..u8:decode(result['text']), -1)
  161.                 elseif result['action']=='ping' then
  162.                     client:send(encodeJson({action='pong'}))
  163.                 end
  164.             end
  165.         end
  166.     end)
  167.     while true do wait(0) imgui.Process = true
  168.         if wasKeyReleased(VK_RBUTTON) and status then mouse_state = not mouse_state end
  169.     end
  170. end
  171. function sampev.onDisplayGameText(style, time, text)
  172.     if text:find('%d+~g~%/~w~10') and (status or cfg_manual_mode.v) then
  173.         lua_thread.create(function()
  174.          stats['apple'] = tonumber(text:match('(%d+)~g~%/~w~10'))
  175.          if  stats['apple']<10 then
  176.              if txd_applecount == 1 then
  177.                  txd_applecount = 0
  178.                  if not cfg_manual_mode.v then start_bot() end
  179.              else
  180.                     txd_applecount = 0
  181.                     pressf()
  182.             end
  183.         elseif stats['apple']==10 then
  184.             stats['status']='Сдаю ящик'
  185.             if not cfg_manual_mode.v then
  186.                 if mode == 'Apple' then BeginToPoint(1915,174,37, 1.5, -255,bool_random[math.random(#bool_random)]) end
  187.                 BeginToPoint(home_cord[mode]['x'],home_cord[mode]['y'],home_cord[mode]['z'], 0.5, -255, bool_random[math.random(#bool_random)])
  188.             end
  189.         end
  190.     end)
  191.         return false
  192.     end
  193. end
  194. function start_bot()
  195.     stats['status']='Поиск фрукта...'
  196.     local object = 0
  197.     while object==0 and status do wait(0)
  198.         local marsh = math.random(#random_place[mode])
  199.         for i=1 ,#random_place[mode] do
  200.             object,x,y,z = getfruit()
  201.             if object ~= 0 then -- Если нашли
  202.                 last_apple = object
  203.             --  print(result)
  204.                 stats['status']='Поиск дерева...'
  205.                 runToTreefromOrange(x,y,z)
  206.                 pressf()
  207.                 while not txd_status and status do wait(1000) if txd_status == false then txd_status = false else pressf() end end
  208.                 break
  209.             elseif status then
  210.                 local place = random_place[mode][marsh][i][math.random(#random_place[mode][marsh][i])]
  211.                 BeginToPoint(place['x'],place['y'],place['z'], 1.5, -255,bool_random[math.random(#bool_random)])
  212.             end
  213.         end
  214.         wait(5000)
  215.     end
  216. end
  217. function sampev.onShowTextDraw(id,data)
  218.         if (data.text == 'Apple' and (status or cfg_manual_mode.v) ) then
  219.             txd_lock = 0
  220.             txd_applecount = txd_applecount+1
  221.             if data.position.y > 200 then
  222.                 txd_lock = 1
  223.                 txd_close_id = -1
  224.                 sampSendClickTextdraw(id)
  225.                 stats['status']='Собираю'
  226.             end
  227.         --  return false
  228.         elseif (data.text=='Close') and (status or cfg_manual_mode.v) then
  229.             txd_status = true
  230.             gopress = true
  231.             txd_close_id = id
  232.             lua_thread.create(function()
  233.                 wait(500)
  234.                 if txd_applecount == 0 then
  235.                     sampSendClickTextdraw(txd_close_id)
  236.                     if not cfg_manual_mode.v then start_bot() end
  237.                 elseif txd_applecount > 0 and txd_close_id>0 then
  238.                     sampSendClickTextdraw(txd_close_id)
  239.                     txd_applecount = 0
  240.                     txd_close_id = 0
  241.                     wait(300)
  242.                     pressf()
  243.                 end
  244.             end)
  245.             --  return false
  246.             elseif ((data.text=='New Textdraw' or data.text:find('KG') or data.text=='Orange' or data.text=='_') and status ) then
  247.             --  return false
  248.             end
  249. end
  250. function sampev.onCreateObject(id,data)
  251.     if data.modelId==1437 and status then
  252.         return false
  253.     end
  254. end
  255. function sampev.onServerMessage(color,text)
  256.     if text:find('%{33AA33%}Вы получили %{FFFFFF%}%d+')   then
  257.         stats['money'] = tonumber(text:match('%{33AA33%}Вы получили %{FFFFFF%}(%d+)'))+stats['money']
  258.         stats['reise'] = stats['reise']+1
  259.         stats['apple'] = 0
  260.         if stats['reise'] < cfg_int_maxreise.v then
  261.             if not cfg_manual_mode.v and status then
  262.                 if vk_send_cd.v then
  263.                         post_reise = post_reise+1
  264.                     if post_reise == vk_int_send_cd.v then
  265.                         sendvkmessage('&#128076; [F-BOT] | '..sampGetPlayerNickname(my_id)..'<br>Состояние: '..stats['reise']..'/'..cfg_int_maxreise.v..'<br>Заработано: '..stats['money']..'$')
  266.                          post_reise=0
  267.                     end
  268.                 end
  269.                 lua_thread.create(function()
  270.                     if mode == 'Apple' then BeginToPoint(1919,184,36, 1.5, -255, bool_random[math.random(#bool_random)]) else BeginToPoint(1789.6571044922,168,31, 1.5, -255, bool_random[math.random(#bool_random)]) end
  271.                     start_bot()
  272.                 end)
  273.             end
  274.         else
  275.             sampAddChatMessage('Задача выполнена', -1)
  276.             if cfg_vk_send_report.v then
  277.                 local   _, my_id =  sampGetPlayerIdByCharHandle(PLAYER_PED)
  278.                 sendvkmessage('&#128176; [F-BOT] | '..sampGetPlayerNickname(my_id)..'<br>Завершил задание: '..stats['reise']..'/'..cfg_int_maxreise.v..'<br>Заработано: '..stats['money']..'$')
  279.             end
  280.         end
  281.     elseif text == '• {FFC800}[Подсказка] {ffffff}Вы проголодались, посетите закусочную или бар' and cfg_eat_msg.v then
  282.         local   _, my_id =  sampGetPlayerIdByCharHandle(PLAYER_PED)
  283.             sendvkmessage('&#127829; [F-BOT] | '..sampGetPlayerNickname(my_id)..'<br>Осталось мало еды, холопа кормить пора!')
  284.     elseif text:find('%{FFC800%}%[Подсказка%] %{ffffff%}Нажмите на %{FF3300%}Enter%{FFFFFF%}') and status and  getDistanceBetweenCoords3d(treecord['x'],treecord['y'], treecord['z'],getCharCoordinates(playerPed))<2 then
  285.         movestatus = false
  286.         pressf()
  287.     elseif text:find('Администратор [A-Za-z_%d+]+%[%d+%]:') and cfg_vk_send_admin.v then
  288.         local   _, my_id =  sampGetPlayerIdByCharHandle(PLAYER_PED)
  289.         sendvkmessage('[F-BOT] | '..sampGetPlayerNickname(my_id)..'<br>Пишет администратор: '..text)
  290.     end
  291. end
  292. function runToTreefromOrange(x,y,z)
  293.     treecord = {}
  294.     local min_dist = 1000
  295.     for k, v in pairs(cord[mode]) do
  296.         local dis = getDistanceBetweenCoords3d(x,y,z,v['x'],v['y'],v['z'])
  297.         if dis < min_dist then
  298.             treecord = {x=v['x'],y=v['y'],z=v['z']}
  299.             min_dist = dis
  300.             current_tree = k
  301.         end
  302.     end
  303.     if (getDistanceBetweenCoords3d(x,y,z,getCharCoordinates(playerPed))>1.3) then
  304.         stats['status']='Двигаюсь к дереву'
  305.         createPickup(19605, 8, treecord['x'],treecord['y'], treecord['z'])
  306.         BeginToPoint(treecord['x'],treecord['y'], treecord['z'], 0.3, -255, false)
  307.         wait(300)
  308.         pressf()
  309.     end
  310. end
  311. function imgui.BeforeDrawFrame()
  312.     if fa_font == nil then
  313.         local font_config = imgui.ImFontConfig() -- to use 'imgui.ImFontConfig.new()' on error
  314.         font_config.MergeMode = true
  315.         fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fa-solid-900.ttf', 33.0, font_config, fa_glyph_ranges)
  316.     end
  317. end
  318. function imgui.OnDrawFrame()
  319.     if imgui_window_menu.v or mouse_state then imgui.ShowCursor = true else imgui.ShowCursor = false end
  320.     if status then
  321.         imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth-30, iScreenHeight/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5,   0.5))
  322.         imgui.SetNextWindowSize(imgui.ImVec2(100, 100), imgui.Cond.FirstUseEver)
  323.         imgui.PushStyleColor(imgui.Col.WindowBg, imgui.ImVec4(0.0, 0.0, 0.0, 0.01))
  324.         imgui.Begin(u8'Pause',-1, imgui.WindowFlags.NoCollapse+imgui.WindowFlags.NoResize+imgui.WindowFlags.NoMove+imgui.WindowFlags.NoTitleBar)
  325.         if imgui.Button('\n'..(pause and fa.ICON_FA_PLAY_CIRCLE or fa.ICON_FA_PAUSE),imgui.ImVec2(60, 55)) then pause = not pause end
  326.         imgui.End()
  327.         imgui.PopStyleColor()
  328.     end
  329.     if imgui_window_menu.v then
  330.         imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth/2, iScreenHeight/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5,    0.5))
  331.         imgui.SetNextWindowSize(imgui.ImVec2(530, 190), imgui.Cond.FirstUseEver)
  332.         imgui.Begin(u8'FB',-1, imgui.WindowFlags.ShowBorders+imgui.WindowFlags.NoCollapse+imgui.WindowFlags.NoResize+imgui.WindowFlags.NoTitleBar)
  333.         imgui.Columns(2,nil,false)
  334.         if imgui.Button('\n'..fa.ICON_FA_USER_COG,imgui.ImVec2(60, 55)) then select_button = 1
  335.         elseif imgui.Button('\n'..fa.ICON_FA_BELL,imgui.ImVec2(60, 55)) then select_button = 2
  336.         elseif imgui.Button('\n'..fa.ICON_FA_POWER_OFF,imgui.ImVec2(60, 55)) then imgui_window_menu.v = false end
  337.         imgui.SetColumnWidth(-1, 75)
  338.         imgui.NextColumn()
  339.         if select_button==2 then
  340.             imgui.CenterColumnText(u8'Сообщения ВКонтакте')
  341.             if imgui.ToggleButton("vk_admin", cfg_vk_send_admin) then mainIni.config.cfg_vk_send_admin = cfg_vk_send_admin.v ; inicfg.save(mainIni, directIni) end
  342.             imgui.SameLine()
  343.             imgui.Text(u8"Если админ пишет")
  344.             if imgui.ToggleButton("vk_report", cfg_vk_send_report) then mainIni.config.cfg_vk_send_report = cfg_vk_send_report.v ; inicfg.save(mainIni, directIni) end
  345.             imgui.SameLine()
  346.             imgui.Text(u8"Отчёт по завершению задания")
  347.             if imgui.ToggleButton("vk_report_cd", vk_send_cd) then mainIni.config.vk_send_cd = vk_send_cd.v ; inicfg.save(mainIni, directIni) end
  348.             imgui.SameLine()
  349.             imgui.Text(u8"Сообщать состояние каждые")
  350.             imgui.SameLine()
  351.             imgui.PushItemWidth(100)
  352.             if imgui.InputInt(u8'рейсов',vk_int_send_cd) then mainIni.config.vk_int_send_cd = vk_int_send_cd.v ; inicfg.save(mainIni, directIni) end
  353.             if imgui.ToggleButton("eat_msg", cfg_eat_msg) then mainIni.config.cfg_eat_msg = cfg_eat_msg.v ; inicfg.save(mainIni, directIni) end
  354.             imgui.SameLine()
  355.             imgui.Text(u8"Если пора жрать")
  356.         elseif select_button==1 then
  357.             if imgui.InputInt(u8'Необходимо кругов',cfg_int_maxreise) then mainIni.config.cfg_int_maxreise = cfg_int_maxreise.v ; inicfg.save(mainIni, directIni) end
  358.             imgui.NewLine()
  359.             if not cfg_manual_mode.v then
  360.                 if imgui.ToggleButton("Trees", cfg_remove_trees) then mainIni.config.cfg_remove_trees = cfg_remove_trees.v ;    inicfg.save(mainIni, directIni) end
  361.                 imgui.SameLine()
  362.                 imgui.Text(u8"Удалять деревья и лестницы")
  363.                 if imgui.ToggleButton("sun", cfg_sun_trees) then mainIni.config.cfg_sun_trees = cfg_sun_trees.v ; inicfg.save(mainIni, directIni) end
  364.                 imgui.SameLine()
  365.                 imgui.Text(u8"Подсветка ближ. дерева")
  366.                 if imgui.ToggleButton("aafk", cfg_aafk) then aafk(cfg_aafk.v); mainIni.config.cfg_aafk = cfg_aafk.v ; inicfg.save(mainIni, directIni) end
  367.                 imgui.SameLine()
  368.                 imgui.Text(u8"Анти-АФК")
  369.             end
  370.             if imgui.ToggleButton("hud", cfg_hud) then mainIni.config.cfg_hud = cfg_hud.v ; inicfg.save(mainIni, directIni) end
  371.             imgui.SameLine()
  372.             imgui.Text(u8"Инфо-худ")
  373.             if imgui.ToggleButton("mmode", cfg_manual_mode) then mainIni.config.cfg_manual_mode = cfg_manual_mode.v ; inicfg.save(mainIni, directIni) end
  374.             imgui.SameLine()
  375.             imgui.Text(u8"Ручной режим")
  376.             imgui.SetCursorPos(imgui.ImVec2(280, 125))
  377.             if mode == 'Apple' then
  378.                  imgui.Button('\n'..fa.ICON_FA_APPLE_ALT..'\nApple',imgui.ImVec2(60, 55))
  379.             else
  380.                 imgui.PushStyleColor(imgui.Col.Button, imgui.ImColor(0.14, 0.12, 0.16, 0):GetVec4())
  381.                     if imgui.Button('\n'..fa.ICON_FA_APPLE_ALT..u8'\nApple' ,imgui.ImVec2(60, 55)) then
  382.                          mode = 'Apple'
  383.                          mainIni.config.mode = mode ; inicfg.save(mainIni, directIni)
  384.                      end
  385.                 imgui.PopStyleColor()
  386.             end
  387.             imgui.SameLine()
  388.             if mode == 'Orange' then
  389.                  imgui.Button('\n'..fa.ICON_FA_CIRCLE..u8'\nOrange',imgui.ImVec2(60, 55))
  390.             else
  391.                 imgui.PushStyleColor(imgui.Col.Button, imgui.ImColor(0.14, 0.12, 0.16, 0):GetVec4())
  392.                     if imgui.Button('\n'..fa.ICON_FA_CIRCLE..u8'\nOrange' ,imgui.ImVec2(60, 55)) then
  393.                          mode = 'Orange'
  394.                          mainIni.config.mode = mode ; inicfg.save(mainIni, directIni)
  395.                       end
  396.                 imgui.PopStyleColor()
  397.             end
  398.             imgui.SetCursorPos(imgui.ImVec2(460, 125))
  399.             if imgui.Button('\n'..(status and fa.ICON_FA_PAUSE or fa.ICON_FA_PLAY_CIRCLE),imgui.ImVec2(60, 55)) then
  400.                 lua_thread.create(function()
  401.                     start_status()
  402.                 end)
  403.             end
  404.         end
  405.         imgui.End()
  406.     end
  407.     if cfg_hud.v then
  408.         imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth-130, iScreenHeight-60), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5,     0.5))
  409.         imgui.SetNextWindowSize(imgui.ImVec2(230, 105), imgui.Cond.FirstUseEver)
  410.         imgui.Begin(u8'FRUIT BOOM ['..thisScript().version..']',-1, imgui.WindowFlags.ShowBorders+imgui.WindowFlags.NoCollapse+imgui.WindowFlags.NoResize)
  411.         imgui.SetCursorPos(imgui.ImVec2(0, 25))
  412.         imgui.Columns(2)
  413.             imgui.SetColumnWidth(-1, 180)
  414.             imgui.Text(u8'Круги:')
  415.             imgui.Text(u8'Фрукты:')
  416.             imgui.Text(u8'Деньги:')
  417.         imgui.NextColumn()
  418.             imgui.Text(tostring(stats['reise'])..'/'.. cfg_int_maxreise.v )
  419.             imgui.Text(stats['apple']..'/10')
  420.             imgui.Text(tostring(stats['money'])..'$')
  421.         imgui.Columns(1)
  422.         imgui.Separator()
  423.         imgui.CenterText(u8:encode(stats['status']))
  424.         imgui.End()
  425.     end
  426. end
  427. function imgui.CenterText(text)
  428.     imgui.SetCursorPosX((imgui.GetWindowSize().x/2) - (imgui.CalcTextSize(text).x / 2))
  429.     imgui.Text(text)
  430. end
  431. function BeginToPoint(x, y, z, radius, move_code, isSprint)
  432.     movestatus = true
  433.     repeat
  434.         local posX, posY, posZ = GetCoordinates()
  435.         set_camera_pos_unfix(x, y,0)
  436.         MovePlayer(move_code, isSprint)
  437.         local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
  438.         while pause do wait(1) end
  439.         wait(0)
  440.     until (dist < radius) or not movestatus
  441.     gopress = false
  442.         if move_code == -255 then
  443.             setVirtualKeyDown(VK_SPACE, false)
  444.         end
  445. end
  446. function MovePlayer(move_code, isSprint)
  447.     setGameKeyState(1, move_code)
  448.     if isSprint then setGameKeyState(16, 255) end
  449. end
  450. function GetCoordinates()
  451.     if isCharInAnyCar(playerPed) then
  452.             local car = storeCarCharIsInNoSave(playerPed)
  453.             return getCarCoordinates(car)
  454.     else
  455.             return getCharCoordinates(playerPed)
  456.         end
  457. end
  458. function SetAngle(x, y, z)
  459.     local posX, posY, posZ = GetCoordinates()
  460.     local pX = x - posX
  461.     local pY = y - posY
  462.     local zAngle = getHeadingFromVector2d(pX, pY)
  463.     if isCharInAnyCar(playerPed) then
  464.         local car = storeCarCharIsInNoSave(playerPed)
  465.         setCarHeading(car, zAngle)
  466.     else
  467.         setCharHeading(playerPed,zAngle)
  468.         end
  469.     restoreCameraJumpcut()
  470. end
  471. function set_camera_pos_unfix(posX, posY)
  472.     local cPosX, cPosY, cPosZ = getActiveCameraCoordinates()
  473.     setCameraPositionUnfixed(0.0, (getHeadingFromVector2d(posX - cPosX, posY - cPosY) - 91.0) / 57.2957795)
  474.  end
  475. function aafk(aafkstat)
  476.  if aafkstat then
  477.     writeMemory(7634870, 1, 1, 1)
  478.     writeMemory(7635034, 1, 1, 1)
  479.     memory.fill(7623723, 144, 8)
  480.     memory.fill(5499528, 144, 6)
  481.  else
  482.     writeMemory(7634870, 1, 0, 0)
  483.     writeMemory(7635034, 1, 0, 0)
  484.     memory.hex2bin('5051FF1500838500', 7623723, 8)
  485.     memory.hex2bin('0F847B010000', 5499528, 6)
  486.     end
  487. end
  488. function apply_custom_style()
  489.     imgui.SwitchContext()
  490.     local style = imgui.GetStyle()
  491.     local colors = style.Colors
  492.     local clr = imgui.Col
  493.     local ImVec4 = imgui.ImVec4
  494.     style.WindowRounding = 4.0
  495.     style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
  496.     style.ChildWindowRounding = 2.0
  497.     style.FrameRounding = 2.0
  498.     style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
  499.     style.ScrollbarSize = 13.0
  500.     style.ScrollbarRounding = 0
  501.     style.GrabMinSize = 8.0
  502.     style.GrabRounding = 1.0
  503.  
  504.     colors[clr.FrameBg]                = ImVec4(0.48, 0.16, 0.16, 0.54)
  505.     colors[clr.FrameBgHovered]         = ImVec4(0.98, 0.26, 0.26, 0.40)
  506.     colors[clr.FrameBgActive]          = ImVec4(0.98, 0.26, 0.26, 0.67)
  507.     colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
  508.     colors[clr.TitleBgActive]          = ImVec4(0.48, 0.16, 0.16, 1.00)
  509.     colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
  510.     colors[clr.CheckMark]              = ImVec4(0.98, 0.26, 0.26, 1.00)
  511.     colors[clr.SliderGrab]             = ImVec4(0.88, 0.26, 0.24, 1.00)
  512.     colors[clr.SliderGrabActive]       = ImVec4(0.98, 0.26, 0.26, 1.00)
  513.     colors[clr.Button]                 = ImVec4(0.98, 0.26, 0.26, 0.40)
  514.     colors[clr.ButtonHovered]          = ImVec4(0.98, 0.26, 0.26, 1.00)
  515.     colors[clr.ButtonActive]           = ImVec4(0.98, 0.06, 0.06, 1.00)
  516.     colors[clr.Header]                 = ImVec4(0.98, 0.26, 0.26, 0.31)
  517.     colors[clr.HeaderHovered]          = ImVec4(0.98, 0.26, 0.26, 0.80)
  518.     colors[clr.HeaderActive]           = ImVec4(0.98, 0.26, 0.26, 1.00)
  519.     colors[clr.Separator]              = colors[clr.Border]
  520.     colors[clr.SeparatorHovered]       = ImVec4(0.75, 0.10, 0.10, 0.78)
  521.     colors[clr.SeparatorActive]        = ImVec4(0.75, 0.10, 0.10, 1.00)
  522.     colors[clr.ResizeGrip]             = ImVec4(0.98, 0.26, 0.26, 0.25)
  523.     colors[clr.ResizeGripHovered]      = ImVec4(0.98, 0.26, 0.26, 0.67)
  524.     colors[clr.ResizeGripActive]       = ImVec4(0.98, 0.26, 0.26, 0.95)
  525.     colors[clr.TextSelectedBg]         = ImVec4(0.98, 0.26, 0.26, 0.35)
  526.     colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
  527.     colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
  528.     colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 0.94)
  529.     colors[clr.ChildWindowBg]          = ImVec4(1.00, 1.00, 1.00, 0.00)
  530.     colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
  531.     colors[clr.ComboBg]                = colors[clr.PopupBg]
  532.     colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
  533.     colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
  534.     colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
  535.     colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
  536.     colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
  537.     colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
  538.     colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
  539.     colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)
  540.     colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
  541.     colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
  542.     colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
  543.     colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
  544.     colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
  545.     colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
  546.     colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
  547. end
  548. apply_custom_style()
  549. function imgui.CenterColumnText(text)
  550.     imgui.SetCursorPosX((imgui.GetColumnOffset() + (imgui.GetColumnWidth() / 2)) - imgui.CalcTextSize(text).x / 2)
  551.     imgui.Text(text)
  552. end
  553. function start_status()
  554.     status = not status
  555.     if status then
  556.         if (cfg_remove_trees.v) then
  557.             for k, v in pairs(getAllObjects()) do
  558.                 if getObjectModel(v) == 673 then
  559.                     deleteObject(v)
  560.                 end
  561.             end
  562.         end
  563.                 start_bot()
  564.     else
  565.         movestatus = false
  566.     end
  567. end
  568. function pressf()
  569.   local data = samp_create_sync_data('player')
  570.   data.keysData = data.keysData + 16
  571.   data.send()
  572. end
  573. function samp_create_sync_data(sync_type, copy_from_player)
  574.     local ffi = require 'ffi'
  575.     local sampfuncs = require 'sampfuncs'
  576.     local raknet = require 'samp.raknet'
  577.     require 'samp.synchronization'
  578.     copy_from_player = copy_from_player or true
  579.     local sync_traits = {
  580.         player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
  581.         vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
  582.         passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
  583.         aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
  584.         trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
  585.         unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
  586.         bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
  587.         spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
  588.     }
  589.     local sync_info = sync_traits[sync_type]
  590.     local data_type = 'struct ' .. sync_info[1]
  591.     local data = ffi.new(data_type, {})
  592.     local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
  593.     -- copy player's sync data to the allocated memory
  594.     if copy_from_player then
  595.         local copy_func = sync_info[3]
  596.         if copy_func then
  597.             local _, player_id
  598.             if copy_from_player == true then
  599.                 _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
  600.             else
  601.                 player_id = tonumber(copy_from_player)
  602.             end
  603.             copy_func(player_id, raw_data_ptr)
  604.         end
  605.     end
  606.     -- function to send packet
  607.     local func_send = function()
  608.         local bs = raknetNewBitStream()
  609.         raknetBitStreamWriteInt8(bs, sync_info[2])
  610.         raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
  611.         raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
  612.         raknetDeleteBitStream(bs)
  613.     end
  614.     -- metatable to access sync data and 'send' function
  615.     local mt = {
  616.         __index = function(t, index)
  617.             return data[index]
  618.         end,
  619.         __newindex = function(t, index, value)
  620.             data[index] = value
  621.         end
  622.     }
  623.     return setmetatable({send = func_send}, mt)
  624. end
  625. function sendvkmessage(text)
  626.     _, my_id =  sampGetPlayerIdByCharHandle(PLAYER_PED)
  627.     user =  sampGetPlayerNickname(my_id)
  628.     local result,code,err_msg = client:send(encodeJson({soft='fbot',
  629.                                                     action='vk',
  630.                                                     serial =  tostring(serial),
  631.                                                     user=tostring(user),
  632.                                                     text=u8:encode(tostring(text))}))
  633.     if not result then
  634.         print('ERROR VK MESS: '..err_msg)
  635.     end
  636. end
  637. function autoupdate(json_url, prefix, url)
  638.   local dlstatus = require('moonloader').download_status
  639.   local json = getWorkingDirectory() .. '\\'..thisScript().name..'-version.json'
  640.   if doesFileExist(json) then os.remove(json) end
  641.   downloadUrlToFile(json_url, json,
  642.     function(id, status, p1, p2)
  643.       if status == dlstatus.STATUSEX_ENDDOWNLOAD then
  644.         if doesFileExist(json) then
  645.           local f = io.open(json, 'r')
  646.           if f then
  647.             local info = decodeJson(f:read('*a'))
  648.             updatelink = info.updateurl
  649.             updateversion = info.latest
  650.             f:close()
  651.             os.remove(json)
  652.             if updateversion ~= thisScript().version then
  653.               lua_thread.create(function(prefix)
  654.                 local dlstatus = require('moonloader').download_status
  655.                 local color = -1
  656.                 wait(250)
  657.                 downloadUrlToFile(updatelink, thisScript().path,
  658.                   function(id3, status1, p13, p23)
  659.                     if status1 == dlstatus.STATUS_DOWNLOADINGDATA then
  660.                       print(string.format('Загружено %d из %d.', p13, p23))
  661.                     elseif status1 == dlstatus.STATUS_ENDDOWNLOADDATA then
  662.                       print('Загрузка обновления завершена.')
  663.  
  664.                       goupdatestatus = true
  665.                       lua_thread.create(function() wait(500) thisScript():reload() end)
  666.                     end
  667.                     if status1 == dlstatus.STATUSEX_ENDDOWNLOAD then
  668.                       if goupdatestatus == nil then
  669.                         update = false
  670.                       end
  671.                     end
  672.                   end
  673.                 )
  674.                 end, prefix
  675.               )
  676.             else
  677.               update = false
  678.             end
  679.           end
  680.         else
  681.           print('v'..thisScript().version..': Не могу проверить обновление. Смиритесь или проверьте самостоятельно на '..url)
  682.           update = false
  683.         end
  684.       end
  685.     end
  686.   )
  687.   while update ~= false do wait(100) end
  688. end
  689. function getfruit()
  690.     local object = 0
  691.     local min_dis = 1000
  692.     local min_cord = {}
  693.     local result,x,y,z = false,nil,nil,nil
  694.     for k, v in ipairs(getAllObjects()) do
  695.         if  (getObjectModel(v) == fruit_model[mode]) and last_apple ~= v then
  696.             result,x,y,z =  getObjectCoordinates(v)
  697.                  local dis  = getDistanceBetweenCoords3d(x,y,z,getCharCoordinates(playerPed))
  698.                  if dis<min_dis then
  699.                         min_dis = dis
  700.                         object = v
  701.                         min_cord = {x=x,y=y,z=z}
  702.             end
  703.         end -- ищем яблоко
  704.     end
  705.     return object,min_cord['x'],min_cord['y'],min_cord['z']
  706. end
Advertisement
Add Comment
Please, Sign In to add comment