Exemple #1
0
/*
==================
G_FloodLimited

Determine whether a user is flood limited, and adjust their flood demerits
Print them a warning message if they are over the limit
Return is time in msec until the user can speak again
==================
*/
int G_FloodLimited( gentity_t *ent )
{
	int deltatime, ms;

	if( g_floodMinTime.integer <= 0 )
		return 0;

	// handles !ent
	if( G_admin_permission( ent, ADMF_NOCENSORFLOOD ) )
		return 0;

	deltatime = level.time - ent->client->pers.floodTime;

	ent->client->pers.floodDemerits += g_floodMinTime.integer - deltatime;
	if( ent->client->pers.floodDemerits < 0 )
		ent->client->pers.floodDemerits = 0;
	ent->client->pers.floodTime = level.time;

	ms = ent->client->pers.floodDemerits - g_floodMaxDemerits.integer;
	if( ms <= 0 )
		return 0;
	trap_SendServerCommand( ent - g_entities, va( "print \"You are flooding: please wait %d second%s before trying again\n",
							( ms + 999 ) / 1000, ( ms > 1000 ) ? "s" : "" ) );
	return ms;
}
Exemple #2
0
/*
=================
G_AdminMessage

Print to all active server admins, and to the logfile, and to the server console
Prepend *prefix, or '[SERVER]' if no *prefix is given
=================
*/
void QDECL G_AdminMessage( const char *prefix, const char *fmt, ... )
{
	va_list argptr;
	char    string[ 1024 ];
	char    outstring[ 1024 ];
	int     i;

	// Format the text
	va_start( argptr, fmt );
	Q_vsnprintf( string, sizeof( string ), fmt, argptr );
	va_end( argptr );

	// If there is no prefix, assume that this function was called directly
	// and we should add one
	if( !prefix || !prefix[ 0 ] )
	{
		prefix = "[SERVER]:";
	}

	// Create the final string
	Com_sprintf( outstring, sizeof( outstring ), "%s " S_COLOR_MAGENTA "%s",
				 prefix, string );

	// Send to all appropriate clients
	for( i = 0; i < level.maxclients; i++ )
		if( G_admin_permission( &g_entities[ i ], ADMF_ADMINCHAT ) ) 
			trap_SendServerCommand( i, va( "chat \"%s\"", outstring ) ); 

	// Send to the logfile and server console
	G_LogPrintf("adminmsg: %s\n", outstring );
}
Exemple #3
0
/*
=================
Cmd_AdminMessage_f

Send a message to all active admins
=================
*/
void Cmd_AdminMessage_f( gentity_t *ent )
{
	char cmd[ sizeof( "say_team" ) ];
	char prefix[ 50 ];
	char *msg;
	int skiparg = 0;

	// Check permissions and add the appropriate user [prefix]
	if( !ent )
	{
		Com_sprintf( prefix, sizeof( prefix ), "[CONSOLE]:" );
	}
	else if( !G_admin_permission( ent, ADMF_ADMINCHAT ) )
	{
		if( !g_publicAdminMessages.integer )
		{
			ADMP( "Sorry, but use of /a by non-admins has been disabled.\n" );
			return;
		}
		else
		{
			Com_sprintf( prefix, sizeof( prefix ), "[PLAYER] %s" S_COLOR_WHITE ":",
					 ent->client->pers.netname );
			ADMP( "Your message has been sent to any available admins and to the server logs.\n" );
		}
	}
	else
	{
		Com_sprintf( prefix, sizeof( prefix ), "[ADMIN] %s" S_COLOR_WHITE ":",
					ent->client->pers.netname );
	}

	// Skip say/say_team if this was used from one of those
	G_SayArgv( 0, cmd, sizeof( cmd ) );
	if( !Q_stricmp( cmd, "say" ) || !Q_stricmp( cmd, "say_team" ) )
	{
		skiparg = 1;
		G_SayArgv( 1, cmd, sizeof( cmd ) );
	}
	if( G_SayArgc( ) < 2 + skiparg )
	{
		ADMP( va( "usage: %s [message]\n", cmd ) );
		return;
	}

	msg = G_SayConcatArgs( 1 + skiparg );

	// Send it
	G_AdminMessage( prefix, "%s", msg );
}
/*
================
G_TeamCommand

Broadcasts a command to only a specific team
================
*/
void G_TeamCommand( team_t team, char *cmd )
{
  int   i;

  for( i = 0 ; i < level.maxclients ; i++ )
  {
    if( level.clients[ i ].pers.connected == CON_CONNECTED )
    {
      if( level.clients[ i ].pers.teamSelection == team ||
        ( level.clients[ i ].pers.teamSelection == TEAM_NONE &&
          G_admin_permission( &g_entities[ i ], ADMF_SPEC_ALLCHAT ) ) )
        trap_SendServerCommand( i, cmd );
    }
  }
}