Ajoute le privilège awards_admin

Modifie la commande /awards en conséquence
This commit is contained in:
sys4-fr 2019-03-03 13:24:28 +01:00
parent cae2c1ee3b
commit 89d4a93f3b

View File

@ -2,28 +2,39 @@
local S = awards.gettext
minetest.register_privilege("awards_admin", { description = "Can manage awards of given player" })
minetest.register_chatcommand("awards", {
params = S("[c|clear|disable|enable]"),
description = S("Show, clear, disable or enable your awards"),
params = "[c|clear|disable|enable] [player_name]",
description = "Show, clear, disable or enable player's awards",
func = function(name, param)
if param == "clear" then
awards.clear_player(name)
minetest.chat_send_player(name,
if not minetest.check_player_privs(name, { awards_admin = true }) then
return false, "You need awards_admin privilege!"
end
local action, playern = param:split(" ")[1], param:split(" ")[2] or name
if action == "clear" then
awards.clear_player(playern)
minetest.chat_send_player(playern,
S("All your awards and statistics have been cleared. You can now start again."))
elseif param == "disable" then
awards.disable(name)
minetest.chat_send_player(name, S("You have disabled awards."))
elseif param == "enable" then
awards.enable(name)
minetest.chat_send_player(name, S("You have enabled awards."))
elseif param == "c" then
awards.show_to(name, name, nil, true)
else
minetest.chat_send_player(name, "All awards and statistics of "..playern.." have been cleared.")
elseif action == "disable" then
awards.disable(playern)
minetest.chat_send_player(playern, "Your awards are disabled.")
minetest.chat_send_player(name, "You have disabled awards of "..playern..".")
elseif action == "enable" then
awards.enable(playern)
minetest.chat_send_player(playern, "Your awards are enabled.")
minetest.chat_send_player(name, "You have enabled awards of "..playern..".")
elseif action == "c" then
awards.show_to(playern, name, nil, true)
elseif not action then
awards.show_to(name, name, nil, false)
else
awards.show_to(action, name, nil, true)
end
if (param == "disable" or param == "enable") and minetest.global_exists("sfinv") then
local player = minetest.get_player_by_name(name)
if (action == "disable" or action == "enable") and minetest.global_exists("sfinv") then
local player = minetest.get_player_by_name(playern)
if player then
sfinv.set_player_inventory_formspec(player)
end