aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgpcf <gpcf@gpcf.eu>2024-07-27 23:01:46 +0200
committergpcf <gpcf@gpcf.eu>2024-07-27 23:01:46 +0200
commit9340e2441c778ce5ba20ad3d7fe56e771560cbbd (patch)
treead16fce8d2e1078ae7d72fe2b4792c444410b573
parent283709204b3a677b570a674535d830b94e2f3696 (diff)
downloadxban2-9340e2441c778ce5ba20ad3d7fe56e771560cbbd.tar.gz
xban2-9340e2441c778ce5ba20ad3d7fe56e771560cbbd.tar.bz2
xban2-9340e2441c778ce5ba20ad3d7fe56e771560cbbd.zip
Add force afk, is_afk lists moderators by afk status now
-rw-r--r--init.lua33
1 files 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 = "<name>",
+ 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 = "<name>",
@@ -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,
})