Noctural

Da Hood Source

Apr 18th, 2023 (edited)
7,792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.08 KB | None | 0 0
  1. local queue_on_teleport = syn and syn.queue_on_teleport or false
  2.  
  3. -- // console
  4. local console = {}
  5. function console.add(name, color)
  6.     color = '@@' .. color:gsub('@', ''):upper() .. '@@'
  7.  
  8.     console[name] = function(...)
  9.         local args = {...}
  10.  
  11.         for i,v in next, args do
  12.             args[i] = tostring(v)
  13.         end
  14.  
  15.         local message = table.concat(args, ' ')
  16.  
  17.         rconsoleprint(color)
  18.         rconsoleprint('\n [' .. os.date('%X', os.time()) .. ']')
  19.         rconsoleprint(' [' .. name .. '] ')
  20.         rconsoleprint('@@LIGHT_GRAY@@')
  21.         rconsoleprint(message)
  22.     end
  23. end
  24.  
  25. console.add('error', 'red')
  26. console.add('log', 'white')
  27. console.add('warn', 'yellow')
  28. console.add('info', 'light_magenta')
  29.  
  30. -- // init
  31. local queueMain = game:HttpGet("https://pastebin.com/raw/AiL8et2t")
  32. if queue_on_teleport then
  33.     queue_on_teleport(queueMain)
  34. end
  35.  
  36. if not isfolder('dahood_farm') then
  37.     console.info("creating 'dahood_farm', 'dahood_farm/last.txt', 'dahood_farm/looted.txt' for first time startup")
  38.     console.info("DaHood Egg Farm by liamm#0223 | discord.gg/hyphon | discord.gg/octo | No Synapse Support by esohasl")
  39.  
  40.     if not queue_on_teleport then
  41.         console.info("No Synapse X found. You can put script in autoexec instead. ")
  42.     end    
  43.  
  44.     makefolder('dahood_farm')
  45.     writefile('dahood_farm/last.txt', tostring(0))
  46.     writefile('dahood_farm/looted.txt', '[]')
  47. end
  48.  
  49. task.spawn(function()
  50. local str = ('|/-\\'):split('')
  51. local count = 1
  52. local looted = 0
  53.  
  54. for i,v in next, game:GetService('HttpService'):JSONDecode(readfile('dahood_farm/looted.txt')) do
  55.     looted += 1
  56. end
  57.  
  58. while true do
  59.     count = count == #str and 1 or count + 1
  60.  
  61.     rconsolename(table.concat({
  62.     'dahood egg farm by liamm#0223',
  63.     'no syn support by esohasl',
  64.     looted .. ' total servers looted'
  65.     }, (' %s '):format(str[count])))
  66.  
  67.     task.wait(0.5)
  68.     end
  69. end)
  70.  
  71. rconsoleprint('\n')
  72. console.warn('waiting for game to load...')
  73. repeat task.wait() until game:IsLoaded()
  74.  
  75. -- // variables
  76. local players = game:GetService('Players')
  77. local http = game:GetService('HttpService')
  78. local teleportservice = game:GetService('TeleportService')
  79. local localplayer = players.LocalPlayer
  80. local character = localplayer.Character or localplayer.CharacterAdded:Wait()
  81. local rootpart
  82.  
  83. -- // functions
  84. function add_looted(jobid)
  85.    local looted = http:JSONDecode(readfile('dahood_farm/looted.txt'))
  86.    looted[jobid] = tick()
  87.    writefile('dahood_farm/looted.txt', http:JSONEncode(looted))
  88. end
  89.  
  90. function get_eggs()
  91.    local eggs = {}
  92.    for i,v in next, workspace.Ignored:GetChildren() do
  93.       if v.Name:match('^Egg') then
  94.          table.insert(eggs, v)
  95.       end
  96.    end
  97.    return eggs
  98. end
  99.  
  100. function collect_eggs()
  101.    local eggs = get_eggs()
  102.    console.info(#eggs, 'eggs found')
  103.    for i,v in next, eggs do
  104.       firetouchinterest(rootpart, v, 0)
  105.       firetouchinterest(rootpart, v, 1)
  106.       console.info('egg collected')
  107.    end
  108. end
  109.  
  110. function refresh_cache()
  111.    console.info('refreshing server cache')
  112.  
  113.    local servers = {}
  114.    local page
  115.  
  116.    repeat
  117.       local response = http:JSONDecode(game:HttpGet('https://games.roblox.com/v1/games/'.. game.PlaceId ..'/servers/Public?sortOrder=Dsc&limit=100' .. (page and '&cursor=' .. page or '')))
  118.       for idx, server in next, response.data do
  119.          table.insert(servers, server)
  120.       end
  121.       page = response.nextPageCursor
  122.    until not page
  123.  
  124.    writefile('dahood_farm/last.txt', tostring(tick()))
  125.    writefile( 'dahood_farm/server_cache.txt', http:JSONEncode(servers) )
  126. end
  127.  
  128. function find_new_server()
  129.    local servers = http:JSONDecode(readfile('dahood_farm/server_cache.txt'))
  130.    local looted = http:JSONDecode(readfile('dahood_farm/looted.txt'))
  131.  
  132.    while task.wait(0.5) do
  133.       console.info(('searching %s available servers...'):format(#servers))
  134.       for idx, server in next, servers do
  135.          if (
  136.          (server.id ~= game.JobId) and
  137.          (tick() - (looted[server.id] or 0) > 3600) and
  138.          (server.playing) and
  139.          (server.playing > 15) and
  140.          (server.playing < 35) ) then
  141.             add_looted(server.id)
  142.             console.info(("teleporting to new server '%s' with %s/%s players"):format(server.id, server.playing, server.maxPlayers))
  143.  
  144.             xpcall(function()
  145.                 teleportservice:TeleportToPlaceInstance(game.PlaceId, server.id)
  146.                 end, function()
  147.                 console.error('teleport error, retrying')
  148.                 find_new_server()
  149.             end)
  150.  
  151.             return
  152.          end
  153.       end
  154.    end
  155. end
  156.  
  157. -- // script
  158.  
  159. if #get_eggs() == 0 then
  160.    console.warn('server has 0 eggs, skipping')
  161. else
  162.    console.warn('waiting for character to load...')
  163.    character:WaitForChild('FULLY_LOADED_CHAR')
  164.    rootpart = character:WaitForChild('HumanoidRootPart')
  165.    collect_eggs()
  166. end
  167.  
  168. if tick() - tonumber(readfile('dahood_farm/last.txt')) > 120 then
  169.    refresh_cache()
  170. end
  171.  
  172. teleportservice.TeleportInitFailed:Connect(function()
  173.     console.error('teleport error, retrying')
  174.     find_new_server()
  175. end)
  176.  
  177. find_new_server()
Advertisement
Add Comment
Please, Sign In to add comment