Advertisement
timmie140

Moon hopper

Nov 23rd, 2024 (edited)
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.01 KB | None | 0 0
  1. -- Full Moon Finder with Server Link Generation and Duplicate Prevention
  2.  
  3. -- Configurations
  4. local WebhookURL = "https://discord.com/api/webhooks/1291821412188819516/d5kzcxW1RI9dSiXBmlwEiduyJalAjSFREm8lu0viDOospXitP5QQyTIAu8g3m0jWaAkk"
  5. local VisitedFileName = "VisitedServers.txt"
  6. local MaxVisitedServers = 20 -- Limit of stored visited servers
  7. local recheckDelay = math.random(45, 90) -- Randomized delay for rechecks
  8. local PlaceId = game.PlaceId
  9. local TeleportService = game:GetService("TeleportService")
  10. local HttpService = game:GetService("HttpService")
  11.  
  12. -- Moon Phases
  13. local MoonPhases = {
  14.     ["1"] = {Icon = "๐ŸŒ”", TextureId = "http://www.roblox.com/asset/?id=9709149680"},
  15.     ["2"] = {Icon = "๐ŸŒ“", TextureId = "http://www.roblox.com/asset/?id=9709150086"},
  16.     ["3"] = {Icon = "๐ŸŒ’", TextureId = "http://www.roblox.com/asset/?id=9709139597"},
  17.     ["4"] = {Icon = "๐ŸŒ‘", TextureId = "http://www.roblox.com/asset/?id=9709135895"},
  18.     ["5"] = {Icon = "๐ŸŒ˜", TextureId = "http://www.roblox.com/asset/?id=9709150401"},
  19.     ["6"] = {Icon = "๐ŸŒ—", TextureId = "http://www.roblox.com/asset/?id=9709143733"},
  20.     ["7"] = {Icon = "๐ŸŒ–", TextureId = "http://www.roblox.com/asset/?id=9709149052"},
  21.     ["8"] = {Icon = "๐ŸŒ•", TextureId = "http://www.roblox.com/asset/?id=9709149431"}
  22. }
  23.  
  24. -- Variables for preventing duplicate messages
  25. local LastMoonPhase = nil
  26. local LastJobId = nil
  27.  
  28. -- Wait for game to load
  29. repeat wait() until game:IsLoaded()
  30.  
  31. -- Read visited servers
  32. local function ReadVisitedServers()
  33.     local visited = {}
  34.     pcall(function()
  35.         local content = readfile(VisitedFileName)
  36.         for jobId in string.gmatch(content, "[^\n]+") do
  37.             table.insert(visited, jobId)
  38.         end
  39.     end)
  40.     return visited
  41. end
  42.  
  43. -- Save visited server
  44. local function SaveVisitedServer(jobId)
  45.     local visited = ReadVisitedServers()
  46.     table.insert(visited, jobId)
  47.     if #visited > MaxVisitedServers then
  48.         table.remove(visited, 1) -- Remove oldest entry if limit exceeded
  49.     end
  50.     writefile(VisitedFileName, table.concat(visited, "\n"))
  51. end
  52.  
  53. -- Detect moon phase
  54. local function GetMoonPhase()
  55.     local Sky = game:GetService("Lighting"):FindFirstChild("Sky")
  56.     if Sky then
  57.         for phase, data in pairs(MoonPhases) do
  58.             if Sky.MoonTextureId == data.TextureId then
  59.                 return tonumber(phase), data.Icon
  60.             end
  61.         end
  62.     end
  63.     return nil, "Unknown"
  64. end
  65.  
  66. -- Generate server join link
  67. local function GenerateServerLinks(placeId, jobId)
  68.     local luaJoinLink = "Roblox.GameLauncher.joinGameInstance(" .. placeId .. ", '" .. jobId .. "')"
  69.     local deeplink = "roblox://placeId=" .. placeId .. "&launchData=" .. jobId
  70.     return luaJoinLink, deeplink
  71. end
  72.  
  73. -- Send webhook notification
  74. local function SendWebhook(MoonPhase, MoonIcon, serverLink, deeplink)
  75.     local embed = {
  76.         ["username"] = "Moon Tracker",
  77.         ["embeds"] = {{
  78.             ["title"] = "Moon Phase Detected",
  79.             ["description"] = string.format("Current Moon: %s (%d%%)", MoonIcon, (MoonPhase or 0) / 8 * 100),
  80.             ["color"] = 65280, -- Green
  81.             ["footer"] = {["text"] = "Full Moon Finder"}
  82.         }}
  83.     }
  84.  
  85.     if serverLink and deeplink then
  86.         embed["embeds"][1]["fields"] = {
  87.             {
  88.                 ["name"] = "Server Join Link (Lua)",
  89.                 ["value"] = string.format("```lua\n%s\n```", serverLink),
  90.                 ["inline"] = false
  91.             },
  92.             {
  93.                 ["name"] = "Server Join Link (Deeplink)",
  94.                 ["value"] = string.format("[Click to Join](%s)", deeplink),
  95.                 ["inline"] = false
  96.             }
  97.         }
  98.     end
  99.  
  100.     local jsonData = HttpService:JSONEncode(embed)
  101.     local success, result = pcall(function()
  102.         request({
  103.             Url = WebhookURL,
  104.             Method = "POST",
  105.             Headers = {["Content-Type"] = "application/json"},
  106.             Body = jsonData
  107.         })
  108.     end)
  109.     if not success then warn("Webhook error:", result) end
  110. end
  111.  
  112. -- Server hop logic
  113. local function AutoServerHop()
  114.     local visitedServers = ReadVisitedServers()
  115.     local foundServer = false
  116.  
  117.     local success, servers = pcall(function()
  118.         return HttpService:JSONDecode(game:HttpGet("https://games.roblox.com/v1/games/" .. PlaceId .. "/servers/Public?sortOrder=Asc&limit=100"))
  119.     end)
  120.  
  121.     if success and servers and servers.data then
  122.         for _, server in ipairs(servers.data) do
  123.             if not table.find(visitedServers, server.id) and server.id ~= game.JobId and server.playing < server.maxPlayers then
  124.                 foundServer = true
  125.                 SaveVisitedServer(server.id)
  126.                 TeleportService:TeleportToPlaceInstance(PlaceId, server.id)
  127.                 break
  128.             end
  129.         end
  130.     end
  131.  
  132.     if not foundServer then
  133.         warn("No valid server found. Rejoining current server.")
  134.         TeleportService:Teleport(PlaceId)
  135.     end
  136. end
  137.  
  138. -- Check moon phase and teleport if necessary
  139. local function CheckMoonPhaseAndHop()
  140.     local moonPhase, moonIcon = GetMoonPhase()
  141.  
  142.     -- Prevent duplicate messages
  143.     if moonPhase == LastMoonPhase and game.JobId == LastJobId then
  144.         print("Moon phase or server did not change. Skipping webhook.")
  145.         return
  146.     end
  147.  
  148.     -- Update last moon phase and job ID
  149.     LastMoonPhase = moonPhase
  150.     LastJobId = game.JobId
  151.  
  152.     -- Generate server links
  153.     local serverLink, deeplink = GenerateServerLinks(PlaceId, game.JobId)
  154.  
  155.     -- Generate webhook message
  156.     if moonPhase and (moonPhase == 7 or moonPhase == 8) then
  157.         SendWebhook(moonPhase, moonIcon, serverLink, deeplink)
  158.         print("Full or near-full moon detected. Server link sent.")
  159.     else
  160.         SendWebhook(moonPhase, moonIcon, nil, nil)
  161.         print("Moon phase not suitable. Server hopping...")
  162.         wait(math.random(2, 5)) -- Add delay for stealth
  163.         AutoServerHop()
  164.     end
  165. end
  166.  
  167. -- Main loop
  168. while true do
  169.     CheckMoonPhaseAndHop()
  170.     wait(recheckDelay)
  171. end
  172.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement