ggm_saytext feature for chat transports

This commit is contained in:
mittorn 2019-02-23 19:20:24 +00:00
parent c6947399ef
commit 1e1eac991d
3 changed files with 35 additions and 0 deletions

View File

@ -2075,6 +2075,8 @@ int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, cha
{
// Parse stuff from args
//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.
// If we wanted to response, we'd write data into response_buffer

View File

@ -3062,6 +3062,36 @@ void GGM_Pause_f( void )
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
@ -3115,6 +3145,7 @@ void GGM_RegisterCVars( void )
g_engfuncs.pfnAddServerCommand( "ggm_load", GGM_Load_f );
g_engfuncs.pfnAddServerCommand( "ggm_votecommand", GGM_VoteCommand_f );
g_engfuncs.pfnAddServerCommand( "ggm_pause", GGM_Pause_f );
g_engfuncs.pfnAddServerCommand( "ggm_saytext", GGM_SayText_f );
zombietime = CVAR_GET_POINTER("zombietime");

View File

@ -204,5 +204,7 @@ int GGM_ChangelevelVote( CBasePlayer *pPlayer, edict_t *pTrigger, const char *ps
void GGM_ClearVote( void );
void GGM_StartVoteCommand( CBasePlayer *pPlayer, const char *pszCommand, const char *pszMessage );
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