Use data stores for code storage. See readme on setting up multiple systems
This commit is contained in:
parent
b542213b7d
commit
8ea54f4b8f
Binary file not shown.
|
@ -3,4 +3,9 @@
|
||||||
## TODO
|
## TODO
|
||||||
- [ ] Make installation instructions
|
- [ ] Make installation instructions
|
||||||
- [ ] Alarm reporting Roblox-Side script
|
- [ ] Alarm reporting Roblox-Side script
|
||||||
- [ ] More detailed Readme
|
- [ ] 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.)
|
|
@ -1,9 +1,16 @@
|
||||||
|
local DataStoreService = game:GetService("DataStoreService")
|
||||||
|
local dataStore = DataStoreService:GetDataStore('securityCodes-' .. script.Parent.dataStoreKey.Value or "XP-99")
|
||||||
|
|
||||||
function setup(parentScript)
|
function setup(parentScript)
|
||||||
-- dont touch
|
-- dont touch
|
||||||
version = "v1.0.1"
|
version = "v1.2.0"
|
||||||
|
|
||||||
-- codes object, will be swapped for data store later
|
-- codes object, will be swapped for data store later
|
||||||
codes = {"1234"}
|
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
|
-- Make a settings object mapped to the values in parentScript.Parent.Settings
|
||||||
settings = {}
|
settings = {}
|
||||||
|
@ -343,6 +350,7 @@ delay
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
codes[tonumber(uid)] = nil
|
codes[tonumber(uid)] = nil
|
||||||
|
dataStore:SetAsync("codes", codes)
|
||||||
ding(1)
|
ding(1)
|
||||||
end
|
end
|
||||||
deauth()
|
deauth()
|
||||||
|
@ -354,6 +362,7 @@ delay
|
||||||
if newCode == newCodeVerify then
|
if newCode == newCodeVerify then
|
||||||
if not table.find(codes, newCode) then
|
if not table.find(codes, newCode) then
|
||||||
codes[tonumber(uid)] = newCode
|
codes[tonumber(uid)] = newCode
|
||||||
|
dataStore:SetAsync("codes", codes)
|
||||||
ding(1)
|
ding(1)
|
||||||
else
|
else
|
||||||
ding(4)
|
ding(4)
|
||||||
|
@ -548,7 +557,7 @@ delay
|
||||||
task.spawn(stateLoop)
|
task.spawn(stateLoop)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function stateLoop()
|
function stateLoop()
|
||||||
while true do
|
while true do
|
||||||
script.Parent.armState.Value = armState
|
script.Parent.armState.Value = armState
|
||||||
|
|
Loading…
Reference in a new issue