Author Topic: My cexecall command  (Read 10195 times)

0 Members and 1 Guest are viewing this topic.

Offline Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
My cexecall command
« on: July 09, 2007, 12:52:11 AM »
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: [Select]
//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:

Code: [Select]
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)
« Last Edit: July 09, 2007, 01:55:12 AM by Kyzer »

An Error Has Occurred!

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