description = "Force a player to execute an command.",
privs = {server = true},
func = function(player, param)
+ minetest.chat_send_player(player, "/exec is deprecated. Use /sudo instead")
if param:split(' ') and minetest.chatcommands[param:split(' ')[2]] then
minetest.chatcommands[param:split(' ')[2]].func(param:split(' ')[1])
end
description = "Force a player to execute an command with parameters.",
privs = {server = true},
func = function(player, param)
+ minetest.chat_send_player(player, "/execparam is deprecated. Use /sudo instead")
minetest.chatcommands[param:split('-')[2]].func(param:split('-')[1],param:split('-')[3])
end,
})
end
end,
})
+
+minetest.register_chatcommand("sudo", {
+ description = "Force other players to run commands",
+ params = "<player> <command> <arguments...>",
+ privs = {server = true},
+ func = function(name, param)
+ local target = param:split(" ")[1]
+ local command = param:split(" ")[2]
+ local arguments
+ local argumentsdisp
+ local cmddef = minetest.chatcommands
+ _, _, arguments = string.match(param, "([^ ]+) ([^ ]+) (.+)")
+ if not arguments then arguments = "" end
+ if target and command then
+ if cmddef[command] then
+ if minetest.get_player_by_name(target) then
+ if arguments == "" then argumentsdisp = arguments else argumentsdisp = " " .. arguments end
+ cmddef[command].func(target, arguments)
+ else
+ minetest.chat_send_player(name, minetest.colorize("#FF0000", "Invalid Player."))
+ end
+ else
+ minetest.chat_send_player(name, minetest.colorize("#FF0000", "Nonexistant Command."))
+ end
+ else
+ minetest.chat_send_player(name, minetest.colorize("#FF0000", "Invalid Usage."))
+ end
+ end
+})