Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- constants
- local RunService = game:GetService("RunService")
- local SECS_IN_DAY = 86400
- -- to customize
- local resetsPerDay = 3
- --local resetsPerDay = 512
- local warningTimes = {60*60, 20*60, 10*60, 5*60, 2*60, 60, 30}
- -- alerts occur at these times before the reset; has to be from greatets to least, and no repeating
- local resetEvery = SECS_IN_DAY/resetsPerDay -- eg secs per reset
- -- functions
- local function SendNotification(plr, text)
- if game.ReplicatedStorage:FindFirstChild("ChatEvent") then
- game.ReplicatedStorage:FindFirstChild("ChatEvent"):FireClient(plr, "Shutdown Warning", text, Color3.new(255/255, 255/255, 25/255), Color3.new(255/255, 255/255, 25/255), "", true, "")
- end
- end
- local function convertToFormat(secsDisplay)
- local hrPart = "0"..math.floor(secsDisplay/3600)
- hrPart = string.sub(hrPart, string.len(hrPart)-1, string.len(hrPart))
- local minPart = "0"..(math.floor(secsDisplay/60)%60)
- minPart = string.sub(minPart, string.len(minPart)-1, string.len(minPart))
- local secsPart = "0"..(math.floor(secsDisplay)%60) -- this is my favorite part
- secsPart = string.sub(secsPart, string.len(secsPart)-1, string.len(secsPart))
- return hrPart..":"..minPart..":"..secsPart
- end
- local function updateDisplay(secsDisplay) -- arg: seconds to display
- script.Sign.SurfaceGui.TextLabel.Text =
- "Time Left Until Shutdown - "..convertToFormat(secsDisplay)
- end
- local function warnThroughNotification(secsDisplay) -- arg: seconds to display
- local warning = convertToFormat(secsDisplay).." until shutdown"
- for i,v in pairs(game.Players:GetPlayers()) do
- SendNotification(v, warning)
- end
- end
- -- waiting and updating billboard
- local secondsLeft = resetEvery - (math.round(tick())%resetEvery)
- local shutdownTick = tick() + secondsLeft
- local warnI = 1
- while warningTimes[warnI] > secondsLeft do warnI+=1 end
- while tick()<shutdownTick do
- updateDisplay(secondsLeft)
- if warnI<#warningTimes and warningTimes[warnI] >= secondsLeft then
- warnThroughNotification(secondsLeft)
- warnI+=1
- end
- task.wait(0.98)
- secondsLeft = resetEvery - (math.round(tick())%resetEvery)
- end
- -- shutting down
- local funnyMessages = {
- "A Rapscalafin has wiped out EG",
- "kinghtgold12 touched the code",
- "GET OUT",
- "ar ar ar ar ar ar ar",
- "collect my pages hidden throughout the spawn"
- }
- local shutdownMessage = "The server has shut down. Reason: "
- if math.random(1,3)==1 then
- shutdownMessage = shutdownMessage..funnyMessages[math.random(1, #funnyMessages)]
- else
- shutdownMessage = shutdownMessage.."None"
- end
- while true do
- for i,v in pairs(game.Players:GetPlayers()) do
- v:Kick(shutdownMessage)
- end
- task.wait(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement