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.
//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 )
Paste this code in 'addons/ulx/lua/ulx/utils.lua', i suggest under the 'cexec' command so things stay grouped.
Example of usage:
ulx cexecall r_cleardecals
ulx cexecall stopsounds
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)