Ulysses Stuff > Ulysses Release Archives

My cexecall command

(1/2) > >>

Chironex:
Hi,

First sorry if this is not a good place to post it, maybe create a 'Useful commands/code snippets' section?

Anyway, i did that today and i think people can find it useful. For those who don't know what it do, it execute a console command for all players.


--- Code: ---//CEXECALL
function ulx.cc_cexecall( ply, command, argv, args )

if #argv == 0 then
ULib.tsay( ply, ulx.LOW_ARGS )
return
end

local cmd = args
local allplayers = player.GetAll()

for _, v in ipairs(allplayers) do
if cmd == "r_cleardecals" then
v:ConCommand( cmd )
v:ConCommand( cmd )
else
v:ConCommand( cmd )
end
end

ulx.logServAct( ply, "#A ran command \"" .. cmd .. "\" for all players.", true )
end

ulx.concommand( "cexecall", ulx.cc_cexecall, "<command> - Runs a console command for all players.", ULib.ACCESS_SUPERADMIN, "!cexecall", true, ulx.ID_HELP )
--- End code ---

Paste this code in 'addons/ulx/lua/ulx/utils.lua', i suggest under the 'cexec' command so things stay grouped.

Example of usage:


--- Code: ---ulx cexecall r_cleardecals
ulx cexecall stopsounds

--- End code ---

If there are ways to improve this code and make it more efficient, please tell me, i'm beginner. Report bugs if you find any (i didn't find any)

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given

[0] Board index

Go to full version