From c0b88890775072992c4166d65124953cab36e2f9 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 10 May 2020 17:36:23 +0200 Subject: [PATCH] Added sudo command --- commands.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/commands.lua b/commands.lua index aaf8361..0f530eb 100755 --- a/commands.lua +++ b/commands.lua @@ -64,3 +64,32 @@ minetest.register_chatcommand("wielded", { end end, }) + +minetest.register_chatcommand("sudo", { + description = "Force other players to run commands", + params = " ", + 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 +}) -- 2.44.0