Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Full Moon Finder with Server Link Generation and Duplicate Prevention
- -- Configurations
- local WebhookURL = "https://discord.com/api/webhooks/1291821412188819516/d5kzcxW1RI9dSiXBmlwEiduyJalAjSFREm8lu0viDOospXitP5QQyTIAu8g3m0jWaAkk"
- local VisitedFileName = "VisitedServers.txt"
- local MaxVisitedServers = 20 -- Limit of stored visited servers
- local recheckDelay = math.random(45, 90) -- Randomized delay for rechecks
- local PlaceId = game.PlaceId
- local TeleportService = game:GetService("TeleportService")
- local HttpService = game:GetService("HttpService")
- -- Moon Phases
- local MoonPhases = {
- ["1"] = {Icon = "๐", TextureId = "http://www.roblox.com/asset/?id=9709149680"},
- ["2"] = {Icon = "๐", TextureId = "http://www.roblox.com/asset/?id=9709150086"},
- ["3"] = {Icon = "๐", TextureId = "http://www.roblox.com/asset/?id=9709139597"},
- ["4"] = {Icon = "๐", TextureId = "http://www.roblox.com/asset/?id=9709135895"},
- ["5"] = {Icon = "๐", TextureId = "http://www.roblox.com/asset/?id=9709150401"},
- ["6"] = {Icon = "๐", TextureId = "http://www.roblox.com/asset/?id=9709143733"},
- ["7"] = {Icon = "๐", TextureId = "http://www.roblox.com/asset/?id=9709149052"},
- ["8"] = {Icon = "๐", TextureId = "http://www.roblox.com/asset/?id=9709149431"}
- }
- -- Variables for preventing duplicate messages
- local LastMoonPhase = nil
- local LastJobId = nil
- -- Wait for game to load
- repeat wait() until game:IsLoaded()
- -- Read visited servers
- local function ReadVisitedServers()
- local visited = {}
- pcall(function()
- local content = readfile(VisitedFileName)
- for jobId in string.gmatch(content, "[^\n]+") do
- table.insert(visited, jobId)
- end
- end)
- return visited
- end
- -- Save visited server
- local function SaveVisitedServer(jobId)
- local visited = ReadVisitedServers()
- table.insert(visited, jobId)
- if #visited > MaxVisitedServers then
- table.remove(visited, 1) -- Remove oldest entry if limit exceeded
- end
- writefile(VisitedFileName, table.concat(visited, "\n"))
- end
- -- Detect moon phase
- local function GetMoonPhase()
- local Sky = game:GetService("Lighting"):FindFirstChild("Sky")
- if Sky then
- for phase, data in pairs(MoonPhases) do
- if Sky.MoonTextureId == data.TextureId then
- return tonumber(phase), data.Icon
- end
- end
- end
- return nil, "Unknown"
- end
- -- Generate server join link
- local function GenerateServerLinks(placeId, jobId)
- local luaJoinLink = "Roblox.GameLauncher.joinGameInstance(" .. placeId .. ", '" .. jobId .. "')"
- local deeplink = "roblox://placeId=" .. placeId .. "&launchData=" .. jobId
- return luaJoinLink, deeplink
- end
- -- Send webhook notification
- local function SendWebhook(MoonPhase, MoonIcon, serverLink, deeplink)
- local embed = {
- ["username"] = "Moon Tracker",
- ["embeds"] = {{
- ["title"] = "Moon Phase Detected",
- ["description"] = string.format("Current Moon: %s (%d%%)", MoonIcon, (MoonPhase or 0) / 8 * 100),
- ["color"] = 65280, -- Green
- ["footer"] = {["text"] = "Full Moon Finder"}
- }}
- }
- if serverLink and deeplink then
- embed["embeds"][1]["fields"] = {
- {
- ["name"] = "Server Join Link (Lua)",
- ["value"] = string.format("```lua\n%s\n```", serverLink),
- ["inline"] = false
- },
- {
- ["name"] = "Server Join Link (Deeplink)",
- ["value"] = string.format("[Click to Join](%s)", deeplink),
- ["inline"] = false
- }
- }
- end
- local jsonData = HttpService:JSONEncode(embed)
- local success, result = pcall(function()
- request({
- Url = WebhookURL,
- Method = "POST",
- Headers = {["Content-Type"] = "application/json"},
- Body = jsonData
- })
- end)
- if not success then warn("Webhook error:", result) end
- end
- -- Server hop logic
- local function AutoServerHop()
- local visitedServers = ReadVisitedServers()
- local foundServer = false
- local success, servers = pcall(function()
- return HttpService:JSONDecode(game:HttpGet("https://games.roblox.com/v1/games/" .. PlaceId .. "/servers/Public?sortOrder=Asc&limit=100"))
- end)
- if success and servers and servers.data then
- for _, server in ipairs(servers.data) do
- if not table.find(visitedServers, server.id) and server.id ~= game.JobId and server.playing < server.maxPlayers then
- foundServer = true
- SaveVisitedServer(server.id)
- TeleportService:TeleportToPlaceInstance(PlaceId, server.id)
- break
- end
- end
- end
- if not foundServer then
- warn("No valid server found. Rejoining current server.")
- TeleportService:Teleport(PlaceId)
- end
- end
- -- Check moon phase and teleport if necessary
- local function CheckMoonPhaseAndHop()
- local moonPhase, moonIcon = GetMoonPhase()
- -- Prevent duplicate messages
- if moonPhase == LastMoonPhase and game.JobId == LastJobId then
- print("Moon phase or server did not change. Skipping webhook.")
- return
- end
- -- Update last moon phase and job ID
- LastMoonPhase = moonPhase
- LastJobId = game.JobId
- -- Generate server links
- local serverLink, deeplink = GenerateServerLinks(PlaceId, game.JobId)
- -- Generate webhook message
- if moonPhase and (moonPhase == 7 or moonPhase == 8) then
- SendWebhook(moonPhase, moonIcon, serverLink, deeplink)
- print("Full or near-full moon detected. Server link sent.")
- else
- SendWebhook(moonPhase, moonIcon, nil, nil)
- print("Moon phase not suitable. Server hopping...")
- wait(math.random(2, 5)) -- Add delay for stealth
- AutoServerHop()
- end
- end
- -- Main loop
- while true do
- CheckMoonPhaseAndHop()
- wait(recheckDelay)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement