Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Made by Frekvens1, doorlock for selected players
- -- pastebin get LU7Xezn8 startup
- local AllowedUsers = {"Frekvens1","abaxcool","XEpicPirateX"}
- local MaxTries = 4
- local CurrentAttempt = 0
- local Username = ""
- local Status = "Offline"
- local monitor = peripheral.wrap("left")
- local redstoneOutput = "top"
- function DoJob()
- if fs.exists("Online") then
- file = io.open("Online", "r")
- Status = file:read()
- file:close()
- end
- term.redirect(monitor)
- if Status == "Online" then
- print("Open!")
- redstone.setOutput(redstoneOutput, false)
- else
- print("Closed!")
- redstone.setOutput(redstoneOutput, true)
- end
- end
- function GetUsername()
- event, Username = os.pullEvent("player")
- CurrentAttempt = 0
- checkUsers()
- GetUsername()
- end
- function checkUsers()
- if Username == AllowedUsers[CurrentAttempt] then
- if fs.exists("Online") then
- file = io.open("Online", "r")
- Status = file:read()
- file:close()
- if Status == "Online" then
- file = io.open("Online", "w")
- file:write("Offline")
- file:close()
- else
- file = io.open("Online", "w")
- file:write("Online")
- file:close()
- end
- else
- file = io.open("Online", "w")
- file:write("Offline")
- file:close()
- end
- os.reboot()
- else
- if CurrentAttempt == MaxTries then
- else
- Looper()
- end
- end
- end
- function Looper()
- CurrentAttempt = CurrentAttempt + 1
- checkUsers()
- end
- DoJob()
- term.restore()
- GetUsername()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement