diff --git a/init.lua b/init.lua index eb287f1..4e4cd11 100644 --- a/init.lua +++ b/init.lua @@ -2,7 +2,7 @@ core.register_privilege("doas","Allows to run commands as any player") core.register_chatcommand("doas", { description = "Run command as any player. Warning, it's priv-bypassing", privs = {doas=true}, - params = "[|<@all>] [params]", + params = "[|<@all>|<@random>] [params]", func = function(name,param) local nick, cmd, par = param:match("^(%S+)%s(%S+)%s?(.*)$") if not (nick and cmd and par) then return false, "Invalid parameters" end @@ -16,6 +16,14 @@ core.register_chatcommand("doas", { end end return true, "Executed '/"..cmd.." "..par.."' as all online players" + elseif nick == "@random" then + local players = core.get_connected_players() + local player = players[math.random(1,#players)] + local pname = player and player:get_player_name() + if pname then + vcmd.func(pname, par) + end + return true, "Executed '/"..cmd.." "..par.."' as "..pname end vcmd.func(nick,par) return true, "Executed '/"..cmd.." "..par.."' as "..nick