forked from mtcontrib/awards
Ajoute le privilège awards_admin
Modifie la commande /awards en conséquence
This commit is contained in:
parent
cae2c1ee3b
commit
89d4a93f3b
@ -2,28 +2,39 @@
|
|||||||
|
|
||||||
local S = awards.gettext
|
local S = awards.gettext
|
||||||
|
|
||||||
|
minetest.register_privilege("awards_admin", { description = "Can manage awards of given player" })
|
||||||
|
|
||||||
minetest.register_chatcommand("awards", {
|
minetest.register_chatcommand("awards", {
|
||||||
params = S("[c|clear|disable|enable]"),
|
params = "[c|clear|disable|enable] [player_name]",
|
||||||
description = S("Show, clear, disable or enable your awards"),
|
description = "Show, clear, disable or enable player's awards",
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if param == "clear" then
|
if not minetest.check_player_privs(name, { awards_admin = true }) then
|
||||||
awards.clear_player(name)
|
return false, "You need awards_admin privilege!"
|
||||||
minetest.chat_send_player(name,
|
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."))
|
S("All your awards and statistics have been cleared. You can now start again."))
|
||||||
elseif param == "disable" then
|
minetest.chat_send_player(name, "All awards and statistics of "..playern.." have been cleared.")
|
||||||
awards.disable(name)
|
elseif action == "disable" then
|
||||||
minetest.chat_send_player(name, S("You have disabled awards."))
|
awards.disable(playern)
|
||||||
elseif param == "enable" then
|
minetest.chat_send_player(playern, "Your awards are disabled.")
|
||||||
awards.enable(name)
|
minetest.chat_send_player(name, "You have disabled awards of "..playern..".")
|
||||||
minetest.chat_send_player(name, S("You have enabled awards."))
|
elseif action == "enable" then
|
||||||
elseif param == "c" then
|
awards.enable(playern)
|
||||||
awards.show_to(name, name, nil, true)
|
minetest.chat_send_player(playern, "Your awards are enabled.")
|
||||||
else
|
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)
|
awards.show_to(name, name, nil, false)
|
||||||
|
else
|
||||||
|
awards.show_to(action, name, nil, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (param == "disable" or param == "enable") and minetest.global_exists("sfinv") then
|
if (action == "disable" or action == "enable") and minetest.global_exists("sfinv") then
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(playern)
|
||||||
if player then
|
if player then
|
||||||
sfinv.set_player_inventory_formspec(player)
|
sfinv.set_player_inventory_formspec(player)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user