Browse Source

ggm_saytext feature for chat transports

gravgun
mittorn 6 years ago
parent
commit
1e1eac991d
  1. 2
      dlls/client.cpp
  2. 31
      dlls/gravgunmod.cpp
  3. 2
      dlls/gravgunmod.h

2
dlls/client.cpp

@ -2075,6 +2075,8 @@ int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, cha
{ {
// Parse stuff from args // Parse stuff from args
//int max_buffer_size = *response_buffer_size; //int max_buffer_size = *response_buffer_size;
if( GGM_ConnectionlessPacket( net_from, args, response_buffer, response_buffer_size ) )
return 1;
// Zero it out since we aren't going to respond. // Zero it out since we aren't going to respond.
// If we wanted to response, we'd write data into response_buffer // If we wanted to response, we'd write data into response_buffer

31
dlls/gravgunmod.cpp

@ -3062,6 +3062,36 @@ void GGM_Pause_f( void )
g_fPause ^= true; g_fPause ^= true;
} }
extern int gmsgSayText;
void GGM_SayText( const char *line )
{
char text[254] = {};
snprintf( text, sizeof( text ), "%s\n", line );
MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
WRITE_BYTE( ENTINDEX(0) );
WRITE_STRING( text );
MESSAGE_END();
}
void GGM_SayText_f( void )
{
GGM_SayText(CMD_ARGS());
}
int GGM_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
{
if( !strncmp( args, "ggm_chat ", 9 ) )
{
GGM_SayText( args + 9 );
*response_buffer_size = 0;
return 1;
}
return 0;
}
/* /*
===================== =====================
GGM_RegisterCVars GGM_RegisterCVars
@ -3115,6 +3145,7 @@ void GGM_RegisterCVars( void )
g_engfuncs.pfnAddServerCommand( "ggm_load", GGM_Load_f ); g_engfuncs.pfnAddServerCommand( "ggm_load", GGM_Load_f );
g_engfuncs.pfnAddServerCommand( "ggm_votecommand", GGM_VoteCommand_f ); g_engfuncs.pfnAddServerCommand( "ggm_votecommand", GGM_VoteCommand_f );
g_engfuncs.pfnAddServerCommand( "ggm_pause", GGM_Pause_f ); g_engfuncs.pfnAddServerCommand( "ggm_pause", GGM_Pause_f );
g_engfuncs.pfnAddServerCommand( "ggm_saytext", GGM_SayText_f );
zombietime = CVAR_GET_POINTER("zombietime"); zombietime = CVAR_GET_POINTER("zombietime");

2
dlls/gravgunmod.h

@ -204,5 +204,7 @@ int GGM_ChangelevelVote( CBasePlayer *pPlayer, edict_t *pTrigger, const char *ps
void GGM_ClearVote( void ); void GGM_ClearVote( void );
void GGM_StartVoteCommand( CBasePlayer *pPlayer, const char *pszCommand, const char *pszMessage ); void GGM_StartVoteCommand( CBasePlayer *pPlayer, const char *pszCommand, const char *pszMessage );
void GGM_ConnectSaveBot( void ); void GGM_ConnectSaveBot( void );
int GGM_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
#endif // GRAVGUNMOD_H #endif // GRAVGUNMOD_H

Loading…
Cancel
Save