Mod to kick idle players
parent
a526faffc2
commit
a1afdabdb6
|
@ -10,6 +10,7 @@ Each mod in the pack is effectively independent, with minimal or no dependencies
|
|||
- `szutil_controlhud`: Togglable on-screen input control HUD, useful for demo recording.
|
||||
- `szutil_fixhack`: Fix lighting and fluid bugs automatically and continuously in background.
|
||||
- `szutil_givemenu`: Menu-driven searchable version of the /give command.
|
||||
- `szutil_idlekick`: Automatically kick idle players after a timeout.
|
||||
- `szutil_lagometer`: Optional on-screen server performance meter HUD.
|
||||
- `szutil_logtrace`: Allow privileged players to monitor server debug trace in chat.
|
||||
- `szutil_maplimitfx`: Display particle visual at hard map boundaries.
|
||||
|
|
10
TODO
10
TODO
|
@ -1,5 +1,7 @@
|
|||
------------------------------------------------------------------------
|
||||
|
||||
- settingtypes.txt for all mods
|
||||
|
||||
- Delayed privileges mod
|
||||
- Countdown modes:
|
||||
- Always-running countdown
|
||||
|
@ -18,6 +20,14 @@
|
|||
- Use other mods that interact w/ privs
|
||||
- Allow creation waiting period via default_privs, motdagree
|
||||
|
||||
- MOTD Agree mod
|
||||
- Initial waiting period in seconds
|
||||
- Queue system, limit number of players eligible to agree to
|
||||
rules at the same time
|
||||
- Require another priv to be able to register (allow use of delayed
|
||||
privs mod)
|
||||
- Limit time player is allowed to be eligible before kick
|
||||
|
||||
- Command alias mod
|
||||
- Allow players to register short command aliases
|
||||
- Store in player metadata per-player
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
------------------------------------------------------------------------
|
||||
|
||||
This mod kicks players who have been idle (no evidence of any input for
|
||||
a certain amount of time) automatically. This can be used to prevent
|
||||
players from idling on a server and using resources, or to automatically
|
||||
disconnect connected devices so players can hop onto a different
|
||||
device even if they left the original device unattended but running.
|
||||
|
||||
The timeout is controlled by the szutil_idlekick_timeout setting, in
|
||||
seconds, defaulting to 600 (10 minutes). The kick reason message can
|
||||
be customized via szutil_idlekick_reason.
|
||||
|
||||
If the szutil_idlekick_invert setting is false, then all players are
|
||||
subject to idle timeout kicks, except those with the szutil_idlekick
|
||||
privilege. If true, then only those with the szutil_idlekick priv are
|
||||
automatically kicked.
|
||||
|
||||
------------------------------------------------------------------------
|
|
@ -0,0 +1,56 @@
|
|||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, pairs, tonumber
|
||||
= minetest, pairs, tonumber
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local invert = minetest.settings:get_bool(modname .. "_invert")
|
||||
local timeout = tonumber(minetest.settings:get(modname .. "_timeout")) or 600
|
||||
local reason = minetest.settings:get(modname .. "_reason") or "idle timeout"
|
||||
|
||||
minetest.register_privilege(modname, {
|
||||
description = (invert and "Kick" or "Do not kick") .. " this player when idle",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = false
|
||||
})
|
||||
|
||||
local times = {}
|
||||
|
||||
local function now() return minetest.get_us_time() / 1000000 end
|
||||
local function bumpn(pname) times[pname] = now() return pname end
|
||||
local function bump(player)
|
||||
if not (player and player.get_player_name) then return end
|
||||
local pname = player:get_player_name()
|
||||
if not pname then return end
|
||||
return bumpn(pname)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player) return bump(player) end)
|
||||
minetest.register_on_placenode(function(_, _, player) return bump(player) end)
|
||||
minetest.register_on_dignode(function(_, _, player) return bump(player) end)
|
||||
minetest.register_on_punchnode(function(_, _, player) return bump(player) end)
|
||||
minetest.register_on_chat_message(function(pname) bumpn(pname) end)
|
||||
minetest.register_on_player_receive_fields(function(player) return bump(player) end)
|
||||
minetest.register_on_craft(function(_, player) return bump(player) end)
|
||||
minetest.register_on_player_inventory_action(function(player) return bump(player) end)
|
||||
|
||||
local looks = {}
|
||||
local function checkplayer(player)
|
||||
local pname = player:get_player_name()
|
||||
local look = player:get_look_dir()
|
||||
local old = looks[pname]
|
||||
looks[pname] = look
|
||||
if player:get_player_control_bits() ~= 0 then return bumpn(pname) end
|
||||
if not (old and vector.equals(old, look)) then return bumpn(pname) end
|
||||
return pname
|
||||
end
|
||||
minetest.register_globalstep(function()
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
if (not minetest.check_player_privs(player, modname)) ~= (not invert) then return end
|
||||
local pname = checkplayer(player)
|
||||
if times[pname] < now() - timeout then
|
||||
minetest.kick_player(pname, reason)
|
||||
end
|
||||
end
|
||||
end)
|
|
@ -0,0 +1 @@
|
|||
name = szutil_idlekick
|
Loading…
Reference in New Issue