mirror of
				https://gitlab.com/rubenwardy/awards.git
				synced 2025-10-31 13:05:22 +01:00 
			
		
		
		
	Ajoute le privilège awards_admin
Modifie la commande /awards en conséquence
This commit is contained in:
		| @@ -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 | ||||||
| 			S("All your awards and statistics have been cleared. You can now start again.")) | 		local action, playern = param:split(" ")[1], param:split(" ")[2] or name | ||||||
| 		elseif param == "disable" then | 		if action == "clear" then | ||||||
| 			awards.disable(name) | 			awards.clear_player(playern) | ||||||
| 			minetest.chat_send_player(name, S("You have disabled awards.")) | 			minetest.chat_send_player(playern, | ||||||
| 		elseif param == "enable" then | 				S("All your awards and statistics have been cleared. You can now start again.")) | ||||||
| 			awards.enable(name) | 			minetest.chat_send_player(name, "All awards and statistics of "..playern.." have been cleared.") | ||||||
| 			minetest.chat_send_player(name, S("You have enabled awards.")) | 		elseif action == "disable" then | ||||||
| 		elseif param == "c" then | 			awards.disable(playern) | ||||||
| 			awards.show_to(name, name, nil, true) | 			minetest.chat_send_player(playern, "Your awards are disabled.") | ||||||
| 		else | 			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) | 			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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user