From 9340e2441c778ce5ba20ad3d7fe56e771560cbbd Mon Sep 17 00:00:00 2001 From: gpcf Date: Sat, 27 Jul 2024 23:01:46 +0200 Subject: Add force afk, is_afk lists moderators by afk status now --- init.lua | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 29c12fb..5a0e1cf 100644 --- a/init.lua +++ b/init.lua @@ -249,14 +249,31 @@ minetest.register_chatcommand("mod_afk", { end xban.present[name] = present if not present then + ACTION("Moderator %s is now afk", name) minetest.chat_send_player(name, "you are now afk") else + ACTION("Moderator %s is now no longer afk", name) minetest.chat_send_player(name, "you are no longer afk") end return true end, }) +minetest.register_chatcommand("force_afk", { + description = "Force moderator to be afk", + params = "", + privs = { kick = true }, + func = function(name, params) + local player = minetest.get_player_by_name(params) + if not player then + minetest.chat_send_player(name, "Player "..params.." is not online.") + return true + end + xban.present[params] = nil + minetest.chat_send_player(params, "[xban] You were set to afk by ".. name) + ACTION("Moderator %s was set to afk by %s", params, name) + end, +}) minetest.register_chatcommand("is_afk", { description = "Check if moderator is afk", params = "", @@ -265,15 +282,21 @@ minetest.register_chatcommand("is_afk", { local players = minetest:get_connected_players() if params == "" then minetest.chat_send_player(name, "You are"..(xban.present[name] and " not" or "").." afk") - return true end for i=1,#players do - if players[i]:get_player_name() == params then - minetest.chat_send_player(name, "Player "..params.." is"..(xban.present[params] and " not" or "").." afk") - return true + local plname = players[i]:get_player_name() + if (params == "" and plname ~= name) or plname == params then + if minetest.get_player_privs(plname).kick then + minetest.chat_send_player(name, "Player "..plname.." is"..(xban.present[plname] and " not" or "").." afk") + end + if plname == params then + return true + end end end - minetest.chat_send_player(name, "Player "..params.." is not online") + if params ~= "" then + minetest.chat_send_player(name, "Player "..params.." is not online") + end end, }) -- cgit v1.2.3