Would someone be able to create a script that would allow the server to display a 2 minute warning to automated server reboots either in the chat or the /yell function preferably the yell function. . My server reboots at 4am , 8am, Noon , 4pm, 8pm and midnight and I would like to display the message "SERVER REBOOT IN 2 MINUTES" just to give a heads up that its a reboot and not a crash. Thank you I look forward to your input.
{REQUEST} Timer Script
- Leftoverjay
- Closed
-
-
-
afaik can't be done well right now, there are no timers in lua and no suitable events in lua api, but you can yell or send a text message to a connected player telling him the time server restarts
-
Would it be possible to display a message at a time of your choice. I guess it wouldn't have to be a timer.
-
There are indeed no timers in Lua, but we have added this functionality for the game. You can create a timer this way:
[lua]setTimer(function, interval, repeats, [arguments]);[/lua]
"function" is the targetfunction that will be triggered by the timer, "interval" is the interval of the timer in seconds (i.e. the delay), "repeats" specifies how often the function should be triggered (use 1 for a single trigger, -1 for infinite) and "arguments" are optional, these are the arguments for your function (if any arguments are required).Here is an example for displaying a label when a player connects and removing it after 5 seconds
[lua]function onPlayerSpawn(event)
local label = Gui:createLabel("Welcome to "..getServer():getServerName().."!", 0.98, 0.135);
label.setPivot(1);
setTimer(destroyLabel, 5, 1, event, label);
endfunction destroyLabel(event, label)
event.player:removeGuiElement(label);
Gui:destroyElement(label);
end[/lua]Of course you can directly define a new function when calling the timer, allowing you to access all variables inside the same block:
[lua] setTimer(function()
event.player:removeGuiElement(label);
Gui:destroyElement(label);
end, 5, 1);[/lua]
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!