12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- local def = 300
- local int = 15
- local to = def
- local function do_shutdown()
- local i, _ = next(minetest.get_connected_players())
- if not i then
- to = to - int
- else
- to = def
- minetest.after(int, do_shutdown)
- return
- end
- if to < 0 then
- minetest.log("action", "autoshutdown")
- minetest.request_shutdown()
- else
- minetest.after(int, do_shutdown)
- end
- end
- minetest.register_chatcommand("autoshutdown", {
- params = "autoshutdown server",
- description = "shut the server down after the last player leaves",
- privs = {server = true},
- func = function(name, param)
- do_shutdown()
- return true, "autoshutdown issued"
- end,
- })
|