Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Change the time for the last time the map existed. Use GMT 0 to
- ]]
- local time = DateTime.fromUniversalTime(2025, 7, 26, 3, 36)
- local DataStoreService = game:GetService("DataStoreService")
- -- Helper function to safely disable the autosave script
- local function disableAutosave()
- local autosaveFolder = game:GetService("ServerScriptService")["april 13"]
- if autosaveFolder then
- -- Look for any scripts inside the folder that might be responsible for autosaving
- for _, child in ipairs(autosaveFolder:GetChildren()) do
- if child:IsA("Script") or child:IsA("ModuleScript") then
- child:Destroy()
- print("Disabled autosave script: " .. child:GetFullName())
- end
- end
- print("All autosave scripts in 'autosave v5 fix 2' have been disabled.")
- else
- warn("Autosave folder 'autosave v5 fix 2' not found")
- end
- end
- -- First recover the metadata to know how many chunks we need to recover
- local metadataStore = DataStoreService:GetDataStore("GlobalMapStore_Meta")
- local listSuccess, metaPages = pcall(function()
- return metadataStore:ListVersionsAsync("MapMetadata", nil, time.UnixTimestampMillis)
- end)
- if listSuccess then
- local metaItems = metaPages:GetCurrentPage()
- if #metaItems > 0 then
- local metaVersion = metaItems[1].Version
- local success, metadata
- success, metadata = pcall(function()
- return metadataStore:GetVersionAsync("MapMetadata", metaVersion)
- end)
- if success and metadata then
- print("Found map metadata from " .. os.date("%Y-%m-%d %H:%M:%S", metadata.lastSaveTime))
- print("Total chunks: " .. metadata.totalChunks)
- -- Restore the metadata first
- metadataStore:SetAsync("MapMetadata", metadata)
- -- Now restore each chunk from each datastore
- local totalChunks = metadata.totalChunks
- local chunksRestored = 0
- local datastoreIndex = 1
- while datastoreIndex <= 200 and chunksRestored < totalChunks do
- local currentStore = DataStoreService:GetDataStore("GlobalMapStore" .. datastoreIndex)
- for i = 1, math.min(5, totalChunks - chunksRestored) do
- local chunkIndex = chunksRestored + 1
- if chunkIndex > totalChunks then break end
- local chunkKey = "GlobalMap_Chunk" .. chunkIndex
- local listSuccess, chunkPages = pcall(function()
- return currentStore:ListVersionsAsync(chunkKey, nil, time.UnixTimestampMillis)
- end)
- if listSuccess then
- local chunkItems = chunkPages:GetCurrentPage()
- if #chunkItems > 0 then
- local chunkVersion = chunkItems[1].Version
- local chunkSuccess, chunkData
- chunkSuccess, chunkData = pcall(function()
- return currentStore:GetVersionAsync(chunkKey, chunkVersion)
- end)
- if chunkSuccess and chunkData then
- currentStore:SetAsync(chunkKey, chunkData)
- print("Restored chunk " .. chunkIndex .. " from GlobalMapStore" .. datastoreIndex)
- chunksRestored = chunksRestored + 1
- else
- warn("Failed to restore chunk " .. chunkIndex)
- end
- else
- warn("No version found for chunk " .. chunkIndex)
- end
- else
- warn("Failed to list versions for chunk " .. chunkIndex)
- end
- end
- datastoreIndex = datastoreIndex + 1
- end
- print("Map restoration complete! Restored " .. chunksRestored .. " of " .. totalChunks .. " chunks.")
- print("Restart the server to load the recovered map.")
- else
- warn("Failed to retrieve metadata version")
- end
- else
- warn("No metadata versions found before the specified time")
- end
- else
- warn("Failed to list metadata versions")
- end
- -- Disable the autosave script after recovery
- disableAutosave()
Advertisement
Add Comment
Please, Sign In to add comment