Get Console Output

Hello,
Its possible to get the console output on the server or client with a lua function or an hook or eventualy in C++ for a module ?

example

Console Input:


say hello world!

Lua code:

[LUA]
hook.Add(“GetConsoleOutput”, “Output”, function( data )
print("Console: " … data)
end)
[/LUA]

Console output:


Console: say hello world!

thanks

Wait… you want a hook that runs whenever something prints to the console, and then you print something to the console in this hook? :psyboom:

http://www.facepunch.com/showthread.php?t=859870 is what you’re looking for, methinks.

I trided with this code but >> hl2.exe has stopped working…

[LUA]
require(“enginespew”)

hook.Add(“EngineSpew”, “ES”, function(spewType, msg, group, level)
if (msg == “hideme”) then
return false --Return anything other than nil to stop the default spew function being called
end

print("…" … tostring(msg) … “…”)

end )
[/LUA]

You are creating an infinite loop right there :smug: [sp]Never call print or Msg in that hook[/sp]

Can you give me an example code please ?

Just pop it to a derma frame or something like that.

intor a derma frame…

if i create a derma frame and i add a textbox in the frame,

and i use that code that works ?

[LUA]
require(“enginespew”)

hook.Add(“EngineSpew”, “ES”, function(spewType, msg, group, level)
if (msg == “hideme”) then
return false --Return anything other than nil to stop the default spew function being called
end

MyDTextentry:SetText(msg)

end )
[/LUA]

Couldn’t you do something like this?

[lua]require( “enginespew” )

local PreventRecur = false

hook.Add( “EngineSpew”, “ES”, function( spewType, msg, group, level )

if ( msg == "hideme" ) then
	return false --Return anything other than nil to stop the default spew function being called
end
if !PreventRecur then
	PreventRecur = true
	print( "............." .. tostring( msg ) .. "............." )
	PreventRecur = false
end

end )[/lua]

Thanks a lot thats works!

but is possible to use that on a server ?

i have tried this on my server my server has crashed :frowning:

Is your server Linux or Windows?

Windows.

No reply ?