this is a bit of a long shot, not sure if it will work for servers -- maybe only clients
there may be numerous calls to messagebegin after a servercommand, or there may be none, this code expects one only. You can catch different msg_types such as HudText, or whatever.
Code:
#include "irecipientfilter.h"
SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write*, IRecipientFilter*, int);
SH_DECL_HOOK0_void(IVEngineServer, MessageEnd, SH_NOATTRIB, 0);
bf_write *current_msg = NULL;
#define BUF_SIZ 1024
char current_msg_buffer[BUF_SIZ];
// ---
///plugin::load()
//{
GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
SH_ADD_HOOK_MEMFUNC(IVEngineServer, UserMessageBegin, engine, this, &MyPlugin::Hook_MessageBegin, true);
SH_ADD_HOOK_MEMFUNC(IVEngineServer, MessageEnd, engine, this, &MyPlugin::Hook_MessageEnd, true);
//}
// --- you're going to take over message begin
bf_write *MyPlugin::Hook_MessageBegin ( IRecipientFilter *filter, int msg_type )
{
// grab the message that will be used for the console
current_msg = SH_CALL(engine, &IVEngineServer::UserMessageBegin)(filter,msg_type);
current_msg_buffer[0] = 0;
RETURN_META_VALUE(MRES_SUPERCEDE,current_msg);
}
void MyPlugin::Hook_MessageEnd ()
{
// probe the current_msg m_pData
// deep copy the data because it might free itself later
strncpy(current_msg_buffer,current_msg->m_pData,BUF_SIZ-1);
current_msg_buffer[BUF_SIZ-1] = 0;
current_msg = NULL;
}
// my plugin
// {
engine->ServerCommand("status");
if ( current_msg_buffer[0] != 0 )
{
// The console stuff should be in current_msg_buffer
}
// }
if it doesn't work, your next best best would be \public\vgui_controls\consoledialog.h
Code:
class CConsolePanel : public vgui::EditablePanel, public IConsoleDisplayFunc
{
// Inherited from IConsoleDisplayFunc
virtual void ColorPrint( const Color& clr, const char *pMessage );
virtual void Print( const char *pMessage );
virtual void DPrint( const char *pMessage );
__________________