intercept console text


(s-men) #1

I would like to intercept everything that has been entered in the console.
So far I figured out how to intercept the chat messages entered through the messagemodes.
I also found CG_ConsoleCommand which checks commands entered in the console, but if the console text didn’t start with an /, then it doesn’t pass there.
So the moment the client enters something in his console window, I need to call my own function from that point and send along what was entered from console.
I’ve been looking for two days now and I just can’t find it.
I hope someone will be able to point it out for me :slight_smile:


(Ragnar_40k) #2

Search for “trap_SendConsoleCommand”, afaik this is the interface between the game code and the engine for console commands.


(s-men) #3

no it doens’t go through there either.
I edited trap_sendconsolecommand to this:

void	trap_SendConsoleCommand( const char *text ) {
	trap_Print("tiet
");
	trap_Print(va("%s
", text));
	syscall( CG_SENDCONSOLECOMMAND, text );
}

and where messagemode text is being handles I added this:

trap_Print("it's not a command
");

result:

As you can see, via messagemode i get my expected output and the output from sendconsolecommand, but when I entered a text into the console it didn’t so I didn’t intercept the message.
Any other ideas?