From 5bb2cff6c5b2fc4bf0276e79330de97114dc018b Mon Sep 17 00:00:00 2001 From: ClobberXD Date: Mon, 3 Dec 2018 21:59:12 +0530 Subject: [PATCH] Fix and improve /reset_rankings --- mods/ctf_stats/gui.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mods/ctf_stats/gui.lua b/mods/ctf_stats/gui.lua index fd3156b..631c1b4 100644 --- a/mods/ctf_stats/gui.lua +++ b/mods/ctf_stats/gui.lua @@ -323,20 +323,31 @@ minetest.register_chatcommand("reset_rankings", { description = "Reset the rankings of yourself or another player", func = function(name, param) param = param:trim() - if param ~= "" and not minetest.check_player_privs(name, { ctf_admin = true}) then + 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 not ctf_stats.players[reset_name] then + return false, "Player '" .. reset_name .. "' does not exist." + end + 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" + minetest.after(30, function() + reset_y[name] = nil + end) + 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, re-type /reset_rankings within 30 seconds to reset." end reset_y[name] = nil - ctf_stats.players[name] = nil + ctf_stats.players[reset_name] = nil ctf_stats.player(reset_name) + ctf.needs_save = true return true, "Successfully reset the stats and ranking of " .. reset_name end })