Add @random
This commit is contained in:
parent
9a141ae29f
commit
16024fdded
10
init.lua
10
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 = "[<playername>|<@all>] <command> [params]",
|
||||
params = "[<playername>|<@all>|<@random>] <command> [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
|
||||
|
Loading…
x
Reference in New Issue
Block a user