- Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.

- Add usage messages for gc, tell, vtell, and votell commands.
- Check player names in gc, tell, vtell, and votell commands.
This commit is contained in:
Zack Middleton 2012-11-18 22:08:58 +00:00
parent 1cdb3b33e7
commit bf9b5cd7de

View file

@ -878,7 +878,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
color = COLOR_CYAN;
break;
case SAY_TELL:
if (target && g_gametype.integer >= GT_TEAM &&
if (target && target->inuse && target->client && g_gametype.integer >= GT_TEAM &&
target->client->sess.sessionTeam == ent->client->sess.sessionTeam &&
Team_GetLocationMsg(ent, location, sizeof(location)))
Com_sprintf (name, sizeof(name), EC"[%s%c%c"EC"] (%s)"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );
@ -943,13 +943,14 @@ static void Cmd_Tell_f( gentity_t *ent ) {
char *p;
char arg[MAX_TOKEN_CHARS];
if ( trap_Argc () < 2 ) {
if ( trap_Argc () < 3 ) {
trap_SendServerCommand( ent-g_entities, "print \"Usage: tell <player id> <message>\n\"" );
return;
}
trap_Argv( 1, arg, sizeof( arg ) );
targetNum = atoi( arg );
if ( targetNum < 0 || targetNum >= level.maxclients ) {
targetNum = ClientNumberFromString( ent, arg );
if ( targetNum == -1 ) {
return;
}
@ -1068,13 +1069,14 @@ static void Cmd_VoiceTell_f( gentity_t *ent, qboolean voiceonly ) {
char *id;
char arg[MAX_TOKEN_CHARS];
if ( trap_Argc () < 2 ) {
if ( trap_Argc () < 3 ) {
trap_SendServerCommand( ent-g_entities, va( "print \"Usage: %s <player id> <voice id>\n\"", voiceonly ? "votell" : "vtell" ) );
return;
}
trap_Argv( 1, arg, sizeof( arg ) );
targetNum = atoi( arg );
if ( targetNum < 0 || targetNum >= level.maxclients ) {
targetNum = ClientNumberFromString( ent, arg );
if ( targetNum == -1 ) {
return;
}
@ -1180,25 +1182,46 @@ static char *gc_orders[] = {
"report"
};
static const int numgc_orders = ARRAY_LEN( gc_orders );
void Cmd_GameCommand_f( gentity_t *ent ) {
int player;
int targetNum;
gentity_t *target;
int order;
char str[MAX_TOKEN_CHARS];
char arg[MAX_TOKEN_CHARS];
trap_Argv( 1, str, sizeof( str ) );
player = atoi( str );
trap_Argv( 2, str, sizeof( str ) );
order = atoi( str );
if ( player < 0 || player >= MAX_CLIENTS ) {
if ( trap_Argc() != 3 ) {
trap_SendServerCommand( ent-g_entities, va( "print \"Usage: gc <player id> <order 0-%d>\n\"", numgc_orders - 1 ) );
return;
}
if ( order < 0 || order > ARRAY_LEN( gc_orders ) ) {
trap_Argv( 1, arg, sizeof( arg ) );
targetNum = ClientNumberFromString( ent, arg );
if ( targetNum == -1 ) {
return;
}
G_Say( ent, &g_entities[player], SAY_TELL, gc_orders[order] );
target = &g_entities[targetNum];
if ( !target || !target->inuse || !target->client ) {
return;
}
trap_Argv( 2, arg, sizeof( arg ) );
order = atoi( arg );
if ( order < 0 || order >= numgc_orders ) {
trap_SendServerCommand( ent-g_entities, va("print \"Bad order: %i\n\"", order));
return;
}
G_LogPrintf( "tell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, gc_orders[order] );
G_Say( ent, target, SAY_TELL, gc_orders[order] );
// don't tell to the player self if it was already directed to this player
// also don't send the chat back to a bot
if ( ent != target && !(ent->r.svFlags & SVF_BOT)) {
G_Say( ent, ent, SAY_TELL, gc_orders[order] );
}
}
/*
==================