Where To Find And Parse Chats


(Downright) #1

Alright been looking around to locate the chat handling functions so that I can incorporate something along the lines of what shrubet did.

So I’ve found:

void	trap_SendConsoleCommand( int exec_when, const char *text ) {
	syscall( G_SEND_CONSOLE_COMMAND, exec_when, text );
}

this calls the system function and I think:

	
static void CG_MessageSend_f( void )
{
                     char	                    messageText[ 256 ];
	int		messageType;
	
	
	// get values
	trap_Cvar_VariableStringBuffer( "cg_messageType", messageText, 256 );
	messageType = atoi( messageText );
	trap_Cvar_VariableStringBuffer( "cg_messageText", messageText, 256 );
	
	// reset values
	trap_Cvar_Set( "cg_messageText", "" );
	trap_Cvar_Set( "cg_messageType", "" );
	trap_Cvar_Set( "cg_messagePlayer", "" );
	 
	// don't send empty messages
	if( messageText[ 0 ] == '\0' )
		return;

this is where the parsing for chats could be done? Any help on how to edit this or if this is even correct would be a huge help. Haven’t dealt with C++ since college and C is close but even more foreign, so bare with me till I get my feet down here.

Thanks


(SCDS_reyalP) #2

I’m not clear at all what you want to do with player chats. Perhaps an example would help.


(Downright) #3

For example:

I have a text file with privs and a player with an allowed priveledge types in !kick <playername> <reason>, it will kick that player. This will be done as a chat (whether to all, team, or fireteam it doesn’t matter)


(SCDS_reyalP) #4

Then you should be looking at game, not cgame. (cgame => client game, game => server game)

Look at G_Say in g_cmds.c

You might also want to think about doing it with client commands instead of chat. Those are also processed in g_cmds.c. Finally, you could add it to the referee system instead.