2CHEVSKII
A reliable way to shutdown your server when you need it.

Supported Games
GameServerKingsGameServerKings

What is it?

This plugin allows you to set up scheduled shutdown times for your server.

Additional features

  • Restart when the new Oxide version is out
  • Fancy UI
  • Flexible API to be used from other plugins

Important notice, please read before posting in the support section

This plugin does not re-launches your server after it was shutdown, because it is not possible. You will need an external solution to that.

Configuration


{
  "Daily restarts": [
    "0:00"
  ],
  "Restart when new Oxide.Rust is out": true,
  "Initiate countdown at": 300,
  "Enable UI": true,
  "UI position (X,Y)": "0.92, 0.92",
  "UI scale": 1.0,
  "Enable console logs": true,
  "Commands": [
    "sr",
    "srestart",
    "smoothrestart",
    "smoothrestarter"
  ],
  "Disable chat countdown notifications": false,
  "Custom countdown reference points": [
    60,
    50,
    40,
    30,
    25,
    15,
    10,
    9,
    8,
    7,
    6,
    5,
    4,
    3,
    2,
    1
  ],
  "Use custom countdown reference points": false,
  "Oxide update check interval in seconds": 600
}

Explanation

  • Daily restarts: This setting allows you to set up time of day, when the server will be shutdown (in hh:mm format)
  • Restart when new Oxide.Rust is out: If set to true - the server will be restarted if current Oxide version is outdated
  • Initiate countdown at: Starting point of the restart countdown (and restart delay for Oxide update restarts). Countdown speed will increase while getting closer to zero
  • Enable UI: Enable or disable plugin UI
  • UI position (X,Y): Sets plugin UI position (0 to 1 floating point number)
  • UI scale: Sets plugin UI relative scale in range from 0.3 to 3
  • Enable console logs: This enables/disables informational console messages
  • Commands: This allows you to change the command used to interact with the plugin, to exclude plugin conflicts and for general convenience
  • Disable chat countdown notifications: Set this to true to disable countdown notifications displayed in chat
  • Custom countdown reference points: Use this to alternate default countdown milestones
  • Use custom countdown reference points: Set this to true to enable previous feature

Localization


{
  "Chat prefix": "<color=#d9770f>Smooth Restarter</color>:",
  "No permission": "<color=#f04c32>You</color> have no permission to use this command",
  "Kick reason": "Server is restarting",
  "Help message": "/sr <color=#1a97ba>[command]</color> <color=#1aba8f>[arguments]</color>\nCommands: <color=#1a97ba>help</color>, <color=#1a97ba>status</color>, <color=#1a97ba>restart</color>, <color=#1a97ba>cancel</color>\nTo get information about command usage, type '/sr <color=#1a97ba>help</color> <color=#1aba8f>[command]</color>'",
  "Help message: Help": "/sr <color=#1a97ba>help</color> <color=#1aba8f>[command]</color> - Outputs general help message or command usage help if command is specified",
  "Help message: Status": "/sr <color=#1a97ba>status</color> - Outputs current restart status",
  "Help message: Restart": "/sr <color=#1a97ba>restart</color> <color=#1aba8f>[time]</color> - Initiates new restart process\nTime must be in one of the following formats:\n<color=#77ba20>123</color> - delay before restart in seconds\n<color=#77ba20>123</color><h|m|s> - delay before restart in <hours|minutes|seconds>\n<color=#77ba20>1</color>h <color=#77ba20>2</color>m <color=#77ba20>3</color>s - delay before restart in hr min sec, all optional\n<color=#77ba20>1</color>:<color=#77ba20>23</color> - schedule restart on 1:23 (24hr format)",
  "Help message: Cancel": "/sr <color=#1a97ba>cancel</color> - Cancels current restart process",
  "Restarting already": "Cannot do restart - already restarting. Use '/sr <color=#1a97ba>status</color>' to get info about current restart process, or try '/sr <color=#1a97ba>cancel</color>' to cancel current restart before starting new one",
  "Not restarting": "Cannot cancel restart - plugin does not perform a restart currently.",
  "Cancelled successfully": "Restart was successfully cancelled",
  "Restart reason: Timed": "Planned",
  "Restart reason: Oxide update": "New Oxide update is out",
  "Restart reason: Command": "Command from <color=#dbc30b>{0}</color>",
  "Restart reason: API call": "API call from <color=#dbc30b>{0}</color>",
  "Announcement: Restart initiated": "Server will be restarted in <color=#a4db0b>{0:sfmt::<hr?  hours ><min?  minutes ><sec?  seconds>}</color> ({1})",
  "Announcement: Countdown tick": "<color=#a4db0b>{0:sfmt::<hr? h ><min? min ><sec? s>}</color> left before server restart",
  "Announcement: Restart cancelled": "Server restart was cancelled",
  "Restart initiated": "Restart initiated successfully",
  "Status: Restarting": "Server is restarting, <color=#a4db0b>{1:sfmt::<min#0.0!  min ><sec?  seconds>}</color> left",
  "Status: Restarting (global.restart)": "Server is restarting natively",
  "Status: Restart planned": "Server restart planned at <color=#a4db0b>{0:hh\\:mm}</color> (<color=#a4db0b>{1:sfmt::<hr?  hours ><min?  minutes ><sec?  seconds>}</color> left)",
  "Status: No planned restarts": "Server is not restarting, no planned restarts found",
  "UI title": "SmoothRestarter",
  "UI countdown format": "{0:sfmt::<min#2!>:<sec#2>} left"
}

Time formatting

Plugin provides custom time formatter with its own syntaxIn the argument format (after the semicolon in the {0:format} placeholders) you can use templates to output different time formats. To enable custom formatting in some particular argument, you need to use sfmt:: prefix, so argument should look like this: {0:sfmt::}After that prefix you can write text which will be in the resulting format, including some templates which get replaced by corresponding values:

  • sec template gets replaced by seconds value
  • min template gets replaced by minutes value
  • hr template gets replaced by hours value

Templates must follow the form of <template_name>, which result in <min> if you want template to be replaced with value of minutes left before restart

Every template can have additional modifiers which alter it's appearance and behaviour:

  • # - Padding and precision modifier allows template to have its numeric value to be padded/truncated
  • ! - Total modifier results in template being replaced by total value of (seconds/minutes/hours) left
  • ? - Optional modifier makes the whole template to be replaced by the empty string in case of numeric value being equal to zero
  • - Appender modifier allows you to append any text to a template (typed between < and >) and have this text behave same as the template (it will not be displayed if the template itself is not, like when we have and optional modifier with value == 0)

Examples are shown below:

Lets suppose we have 30 minutes and 23 seconds left before restart (30 * 60 23 = 1823 seconds total, or 30,383333 minutes total)Format of <hr>:<min>:<sec> will obviously result in 0:30:23, which is not a pretty number is it?But we can use <hr?:><min?>:<sec?> which will display 30:23 as a result in this case while still showing 1:30:23, if we have 1 hour 30 minutes and 23 seconds left

If you want to take a step further and make all the numbers appear in form of two digits (prepended with 0 while necessary), you can use # padding and precision modifier which helps in this case.<hr#2?:><min#2?:><sec#2?> will be outputted as 01:30:23

If you do not want to display hours, but just use value of minutes and seconds left before restart - use the ! total modifier. Lets say restart will happen in 3 hours, 59 minutes and 17 seconds.If we use the format of <min! minutes ><sec seconds> to display the value as "239 minutes 17 seconds", because our hours value gets transformed into 180 minutes, plus 59 minutes we have which results in 239.The same value of 3 hours, 59 minutes and 17 seconds is total of 239.28333333333 minutes, but the decimal part is hidden by default. What if you want to show it instead of seconds? # padding and precision operator will help us do that as well, just set the format to be <min#0.3! minutes> and the resulting value will be "239.283 minutes", because we use 3 as the precision value, which can actually be any other number greater or equal to zero

Commands

Command prefix is configurable in the configuration, /srestart is used as an example

  • srestart status - Will respond with informational message if server is restarting or not (and the time left)
  • srestart cancel - Cancels current restart process, will also cancel restart initiated by global.restart command
  • srestart restart <time> - Initiates restart process, see Supported formats to understand <time> argument format
  • srestart help (<command>) - Outputs general help message, or info about <command> usage, if present

Supported formats by the time command

  • 123 - Delay in seconds
  • 123<h|m|s> - Delay in hours/minutes/seconds
  • 1h 2m 3s - Delay of 1 hour, 2 minutes and 3 seconds, total of 3723 seconds. All sections are optional
  • 1:23 - Schedules restart for 01:23 real time (24hr format)

Native restart interaction

Plugin handles checks for native restart processes (global.restart console command). While you can cancel it with /sr cancel command, you will not be able to initiate new restart process before doing so, neither timed/Oxide update restarts will proceed while native restart is running, so pay attention to this behaviour.

Permissions

Each permission grants access to the respective plugin command (e.g. smoothrestarter.status for /sr status):

  • smoothrestarter.restart
  • smoothrestarter.cancel
  • smoothrestarter.status

In most cases you would want to have smoothrestarter.status granted to all players while other commands are only available to admins

UI

Plugin provides simple UI to indicate current restart process' status. UI can be scaled and moved around the screen by manipulating values in the configUI progress bar color is updated automatically relative to the time left before restart

ui_greenui_yellow

ui_red

Additional options

If you want to provide players with rewards if they return to play on your server after a restart happened - be sure to check out Smooth Restarter Rejoin Rewards which provides customizable functionality for this purpose

Developer API

/* Callable hooks */
IsSmoothRestarting(): bool // returns true if plugin is going to restart server
GetPlannedRestarts(): IReadOnlyCollection<TimeSpan> // returns list of planned restarts
GetCurrentRestartTime(): Nullable<DateTime> // returns DateTime indicating when the server will be restarted, if restarting currently, otherwise null
GetCurrentRestartReason(): Nullable<int> // returns number corresponding to RestartReason enum (see below), if restarting, otherwise null
GetCurrentRestartInitiator(): object // returns Plugin or IPlayer if restart initiated by API call / Command respectively, otherwise null
InitSmoothRestart(DateTime, Plugin): bool // Accepts DateTime as a timestamp to restart at and Plugin as restart initiator, returns true if successfull
CancelSmoothRestart(Plugin): bool // Accepts Plugin as a canceller and returns true if successfull
/* Informational hooks */
OnSmoothRestartInit(float, RestartReason, object) // Called whenever new restart process has started. Passes remaining time in seconds, RestartReason (see below), initiator (Plugin/IPlayer/null) as parameters
OnSmoothRestartTick(int) // Called when a countdown tick happens. Passes remaining time in seconds as a parameter
OnSmoothRestartCancelled(object) // Called when restart process was cancelled. Passes IPlayer/Plugin as a parameter
/* RestartReason enum */
// Timed = 0
// OxideUpdate = 1
// Command = 2
// ApiCall = 4

Credits

  • Visagalis, the original author of this plugin
  • Fujikura, previous maintainer of the plugin

This plugin has a complex license because the original author does not have a public email or other contact method reachable by the current plugin maintainer.


Code of the plugin (starting from 2.0.0 update) was written from scratch by the current maintainer - 2CHEVSKII and is licensed under the MIT open-source license.
Full license text can be found at https://www.tldrlegal.com/l/mit


Plugin name and idea belongs to an original author: Visagalis


Plugin icon is original and all the rights reserved to the current maintainer - 2CHEVSKII