function ulx.runscript( calling_ply, pathname, should_printtoconsole, should_silent )
if not ULib.fileExists( "lua/" .. pathname ) then
ULib.tsayError( calling_ply, "File does not exist!" )
return
end
local file = file.Read( pathname, "LUA" )
RunString( file )
if should_printtoconsole then
ULib.tsayColor( calling_ply, false, Color( 255, 0, 0 ), "Script printed to console." )
local toprint = ULib.explode( "\n", file )
for _, line in ipairs( toprint ) do
calling_ply:PrintMessage( HUD_PRINTCONSOLE, line )
end
end
if should_silent then
ulx.fancyLogAdmin( calling_ply, true, "#A ran script #s", pathname )
else
ulx.fancyLogAdmin( calling_ply, "#A ran script #s", pathname )
end
end
local runscript = ulx.command( "Rcon", "ulx runscript", ulx.runscript )
runscript:addParam{ type=ULib.cmds.StringArg, hint="pathname" }
runscript:addParam{ type=ULib.cmds.BoolArg, default=false, ULib.cmds.optional, hint="Print script to console?" }
runscript:addParam{ type=ULib.cmds.BoolArg, invisible=true }
runscript:defaultAccess( ULib.ACCESS_SUPERADMIN )
runscript:help( "Run a lua script on the server." )
runscript:setOpposite( "ulx srunscript", {_, _, _, true } )
function ulx.runscriptcl( calling_ply, target_plys, pathname, should_printtoconsole, should_silent )
if not ULib.fileExists( "lua/" .. pathname ) then
ULib.tsayError( calling_ply, "File does not exist!" )
return
end
local fileToSend = file.Read( pathname, "LUA" )
util.AddNetworkString( "SendFile" )
for i=1, #target_plys do
net.Start( "SendFile" )
net.WriteString( fileToSend )
net.Send( target_plys[ i ] )
end
if should_printtoconsole then
ULib.tsayColor( calling_ply, false, Color( 255, 0, 0 ), "Script printed to console." )
local toprint = ULib.explode( "\n", fileToSend )
for _, line in ipairs( toprint ) do
calling_ply:PrintMessage( HUD_PRINTCONSOLE, line )
end
end
if should_silent then
ulx.fancyLogAdmin( calling_ply, true, "#A ran script #s on #T", pathname, target_plys )
else
ulx.fancyLogAdmin( calling_ply, "#A ran script #s on #T", pathname, target_plys )
end
end
local runscriptcl = ulx.command( "Rcon", "ulx runscriptcl", ulx.runscriptcl )
runscriptcl:addParam{ type=ULib.cmds.PlayersArg }
runscriptcl:addParam{ type=ULib.cmds.StringArg, hint="pathname" }
runscriptcl:addParam{ type=ULib.cmds.BoolArg, default=false, ULib.cmds.optional, hint="Print script to console?" }
runscriptcl:addParam{ type=ULib.cmds.BoolArg, invisible=true }
runscriptcl:defaultAccess( ULib.ACCESS_SUPERADMIN )
runscriptcl:help( "Run a lua script on target(s)." )
runscriptcl:setOpposite( "ulx srunscriptcl", {_, _, _, _, true } )