Console output grabber

I want a module that grabs the whole console output and pushes that into a lua func.

Need any further description? :slight_smile:

I would also like this. Would be useful to me.

Still noone to do this? :l

Possible to hook Msg calls in C++ to Lua?

#include <windows.h>
#include "vfnhook.h"
#include "sigscan.h"

#include <steam/steamclientpublic.h>
#include <interface.h>
#include <netadr.h>
#include <iclient.h>
#include <iserver.h>

#include "common/GMLuaModule.h"

GMOD_MODULE(Load, Unload)

typedef void unknown_ret;

// None of these are used vOv
class CBaseClient;
class CClientFrame;
class CFrameSnapshot;
class bf_write;

CBaseServer* pServer = NULL;
ILuaInterface* gLua = NULL;

DEFVFUNC_(origMsg, bool, (char const* SMsg));
bool VFUNC newMsg(char const* SMsg)
		gLua->PushNil(); // Gamemode (Unnecessary, always nil)
	gLua->Call(3, 1);

	return origMsg(SMsg);

int Load(lua_State* L)
	gLua = Lua();

	CSigScan::sigscan_dllfunc = Sys_GetFactory("engine.dll");
	if ( !CSigScan::GetDllMemInfo() )
		gLua->Error("CSigScan::GetDllMemInfo failed!");

	CSigScan sigBaseServer;
	sigBaseServer.Init((unsigned char *)
		"????xxxxxxxxx????xx", 10);

	if ( !sigBaseServer.is_set )
		gLua->Error("CBaseServer signature failed!");

	pServer = *(CBaseServer**) sigBaseServer.sig_addr;
	HOOKVFUNC(pServer, 57, origMsg, newMsg);

	return 0;

int Unload(lua_State* L)
	if ( pServer )
		UNHOOKVFUNC(pServer, 57, origMsg);

	return 0;

That only hooks to console output on the server.

I believe Stoned wants it for the client.

This would be very useful, hope someone attempts it.

As Chris said only serverside and I guess that garry will remove con_logfile serverside soon :slight_smile:

I’d like to be able to capture the ‘stats’ output to monitor the CPU usage of the server… Anyone else know of another way? I know about the module that does this but it’s very laggy and I’d like to run it every 5 seconds or so…