Use data stores for code storage. See readme on setting up multiple systems

This commit is contained in:
Christopher Cookman 2024-07-30 22:41:30 -06:00
parent b542213b7d
commit 8ea54f4b8f
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
3 changed files with 18 additions and 4 deletions

View file

@ -4,3 +4,8 @@
- [ ] Make installation instructions
- [ ] Alarm reporting Roblox-Side script
- [ ] More detailed Readme
- [X] Use datastores for code storage
## Having multiple separate systems
To put it simply, you just need to set the `dataStoreKey` string to *anything you want*
If you want systems to share codes, use the same dataStoreKey (This is not supported, and may cause issues.)

View file

@ -1,9 +1,16 @@
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore('securityCodes-' .. script.Parent.dataStoreKey.Value or "XP-99")
function setup(parentScript)
-- dont touch
version = "v1.0.1"
version = "v1.2.0"
-- codes object, will be swapped for data store later
codes = dataStore:GetAsync("codes")
if not codes then
codes = {"1234"}
dataStore:SetAsync("codes", codes)
end
-- Make a settings object mapped to the values in parentScript.Parent.Settings
settings = {}
@ -343,6 +350,7 @@ delay
return
else
codes[tonumber(uid)] = nil
dataStore:SetAsync("codes", codes)
ding(1)
end
deauth()
@ -354,6 +362,7 @@ delay
if newCode == newCodeVerify then
if not table.find(codes, newCode) then
codes[tonumber(uid)] = newCode
dataStore:SetAsync("codes", codes)
ding(1)
else
ding(4)