SythicalScripts

Sythical | Script

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