Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DSS3 = {}
- local DataStoreService = game:GetService("DataStoreService")
- local RunService = game:GetService("RunService")
- ----------------------------------------- // Base Functions (Save, Load, Update, Remove, CheckForData)
- function DSS3.SetData(Store,Player,Data)
- for i = 1,10 do
- local S, R = pcall(function()
- local NewStore = DataStoreService:GetDataStore(Store)
- NewStore:SetAsync(Player,Data)
- end)
- if S then
- print("Set Data")
- break
- else
- print("DSS Error:")
- print(R)
- wait(2)
- end
- end
- end
- function DSS3.UpData(Store,Player,Data)
- for i = 1,10 do
- local S, R = pcall(function()
- local NewStore = DataStoreService:GetDataStore(Store)
- NewStore:UpdateAsync(Player,Data)
- end)
- if S then
- break
- else
- print("DSS Error:")
- print(R)
- wait(2)
- end
- end
- end
- function DSS3.GetData(Store,Player)
- local Result
- for i = 1,10 do
- local S, R = pcall(function()
- local NewStore = DataStoreService:GetDataStore(Store)
- Result = NewStore:GetAsync(Player)
- end)
- if S then
- return Result
- else
- print("DSS Error:")
- print(R)
- wait(2)
- end
- end
- end
- function DSS3.RemoveData(Store,Player)
- for i = 1,10 do
- local S, R = pcall(function()
- local NewStore = DataStoreService:GetDataStore(Store)
- NewStore:RemoveAsync(Player)
- end)
- if S then
- print("Removed Data")
- break
- else
- print("DSS Error:")
- print(R)
- wait(2)
- end
- end
- end
- function DSS3.CheckForExistingData(Store,Player)
- local Data
- for i = 1,#3 do
- local S, R = pcall(function()
- Data = DSS3.GetData(Store,Player)
- if Data == nil then
- local Result = false
- return Result
- else
- end
- end)
- wait(1)
- if S then
- break
- end
- end
- if Data == nil then
- local Result = true
- return Result
- end
- end
- ----------------------------------------- // ArraySaving, ArrayLoading
- function DSS3.SaveArray(Store,Player,Data)
- local Combined = table.concat(Data,";Split;")
- DSS3.SetData(Store,Player,Data)
- end
- function DSS3.LoadArray(Store,Player)
- return string.split(DSS3.GetData(Store,Player),";Split;")
- end
- ----------------------------------------- // DataStore Listing (For BackUps or Databases)
- function DSS3.CreateListing(Store,Data)
- for i = 1,10 do
- local S, R = pcall(function()
- local EntryCount = DSS3.GetData(Store .. "EntryCount","EntryCount")
- if tonumber(EntryCount) == nil then
- EntryCount = 0
- end
- EntryCount = tostring(tonumber(EntryCount) + 1)
- DSS3.SetData(Store,EntryCount,Data)
- DSS3.SetData(Store .. "EntryCount","EntryCount",EntryCount)
- end)
- if S then
- break
- else
- print("DSS Error:")
- print(R)
- wait(2)
- end
- end
- end
- function DSS3.GetListings(Store)
- local StoreNames = {}
- for i = 1,10 do
- local S, R = pcall(function()
- local EntryCount = DSS3.GetData(Store .. "EntryCount","EntryCount")
- EntryCount = tonumber(EntryCount)
- StoreNames = {}
- for i = 1, EntryCount do
- local Name = tostring(i)
- table.insert(StoreNames,Name)
- end
- end)
- if S then
- return StoreNames
- else
- print("DSS Error:")
- print(R)
- wait(2)
- end
- end
- end
- function DSS3.RemoveListing(Store,Number)
- DSS3.SetData(Store,Number,nil)
- end
- function DSS3.GetEntryCount(Store)
- local EntryCount = DSS3.GetData(Store .. "EntryCount","EntryCount")
- EntryCount = tonumber(EntryCount)
- return EntryCount
- end
- ----------------------------------------- // Save Or Load Models (Via My Modules)
- local PartSavingMod = require(script.PartSavingModule)
- function DSS3.SaveModel(Model)
- return PartSavingMod.GetModelProperties(Model)
- end
- local PartLoadMod = require(script.PartLoadingModule)
- function DSS3.LoadModel(Model)
- return PartLoadMod.LoadModel(Model)
- end
- ----------------------------------------- // Time And Date
- local TimeAndDateMod = require(script.TimeAndDateMod)
- function DSS3.GetSecondsPassed()
- return TimeAndDateMod.SecondTime()
- end
- ----------------------------------------- // GetBackup Data
- function DSS3.GetBackup(Store)
- print("Attempting To Get Backup Data from" .. Store)
- local Backups = DSS3.GetListings(Store)
- local Data = {}
- Data[1] = #Backups
- while Data[3] ~= nil do
- Data[2] = DSS3.GetData(Backups[Data[1]])
- if Data[2] == nil then
- -- Data May Be Corrupted
- Data[1] = Data[1] - 1
- else
- Data[3] = Data[2]
- end
- end
- if Data[3] then
- return Data[3]
- else
- print("No Usable Backups Found")
- end
- end
- ----------------------------------------- // Returns The DSS3 Module
- return DSS3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement