From d5f6296c1142ad63eb02047ffbfb464f829b8d06 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sat, 27 Jan 2018 00:01:17 +0000 Subject: [PATCH] Add reset_rankings command --- mods/ctf_stats/gui.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mods/ctf_stats/gui.lua b/mods/ctf_stats/gui.lua index 4cbe092..b33e244 100644 --- a/mods/ctf_stats/gui.lua +++ b/mods/ctf_stats/gui.lua @@ -180,3 +180,25 @@ minetest.register_chatcommand("rankings", { end end }) + +local reset_y = {} +minetest.register_chatcommand("reset_rankings", { + func = function(name, param) + param = param:trim() + if param ~= "" and not minetest.check_player_privs(name, { ctf_admin = true}) then + return false, "Missing privilege: ctf_admin" + end + + local reset_name = param == "" and name or param + + if reset_name == name and not reset_y[name] then + reset_y[name] = true + return true, "This will reset your stats and rankings completely. You will lose access to any special privileges such as the team chest or userlimit skip. This is irreversable. If you're sure, type /reset_rankings again to perform the reset" + end + reset_y[name] = nil + + ctf_stats.players[name] = nil + ctf_stats.player(reset_name) + return true, "Reset the stats and ranking of " .. reset_name + end +})