mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-10 14:41:42 +00:00
- 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:
parent
1cdb3b33e7
commit
bf9b5cd7de
1 changed files with 42 additions and 19 deletions
|
@ -878,7 +878,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
|
||||||
color = COLOR_CYAN;
|
color = COLOR_CYAN;
|
||||||
break;
|
break;
|
||||||
case SAY_TELL:
|
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 &&
|
target->client->sess.sessionTeam == ent->client->sess.sessionTeam &&
|
||||||
Team_GetLocationMsg(ent, location, sizeof(location)))
|
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 );
|
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 *p;
|
||||||
char arg[MAX_TOKEN_CHARS];
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
trap_Argv( 1, arg, sizeof( arg ) );
|
trap_Argv( 1, arg, sizeof( arg ) );
|
||||||
targetNum = atoi( arg );
|
targetNum = ClientNumberFromString( ent, arg );
|
||||||
if ( targetNum < 0 || targetNum >= level.maxclients ) {
|
if ( targetNum == -1 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,13 +1069,14 @@ static void Cmd_VoiceTell_f( gentity_t *ent, qboolean voiceonly ) {
|
||||||
char *id;
|
char *id;
|
||||||
char arg[MAX_TOKEN_CHARS];
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
trap_Argv( 1, arg, sizeof( arg ) );
|
trap_Argv( 1, arg, sizeof( arg ) );
|
||||||
targetNum = atoi( arg );
|
targetNum = ClientNumberFromString( ent, arg );
|
||||||
if ( targetNum < 0 || targetNum >= level.maxclients ) {
|
if ( targetNum == -1 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1180,24 +1182,45 @@ static char *gc_orders[] = {
|
||||||
"report"
|
"report"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int numgc_orders = ARRAY_LEN( gc_orders );
|
||||||
|
|
||||||
void Cmd_GameCommand_f( gentity_t *ent ) {
|
void Cmd_GameCommand_f( gentity_t *ent ) {
|
||||||
int player;
|
int targetNum;
|
||||||
int order;
|
gentity_t *target;
|
||||||
char str[MAX_TOKEN_CHARS];
|
int order;
|
||||||
|
char arg[MAX_TOKEN_CHARS];
|
||||||
|
|
||||||
trap_Argv( 1, str, sizeof( str ) );
|
if ( trap_Argc() != 3 ) {
|
||||||
player = atoi( str );
|
trap_SendServerCommand( ent-g_entities, va( "print \"Usage: gc <player id> <order 0-%d>\n\"", numgc_orders - 1 ) );
|
||||||
trap_Argv( 2, str, sizeof( str ) );
|
|
||||||
order = atoi( str );
|
|
||||||
|
|
||||||
if ( player < 0 || player >= MAX_CLIENTS ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( order < 0 || order > ARRAY_LEN( gc_orders ) ) {
|
|
||||||
|
trap_Argv( 1, arg, sizeof( arg ) );
|
||||||
|
targetNum = ClientNumberFromString( ent, arg );
|
||||||
|
if ( targetNum == -1 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
G_Say( ent, &g_entities[player], SAY_TELL, gc_orders[order] );
|
|
||||||
G_Say( ent, ent, 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] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue