diff options
author | Pan7 <panter@gmx.net> | 2014-07-18 00:15:05 +0200 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2016-04-07 10:59:44 +0100 |
commit | f1a51e13c659ac80ccc2e9bc453d7e671262d564 (patch) | |
tree | a9d742443d5986d9e7ecfd9700dc8d7a7095c477 /src/server | |
parent | 982f409cecd73c70a0a7c5e6559696776b6c6dd5 (diff) |
sayto cmd with player name completion
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/sv_ccmds.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/server/sv_ccmds.c b/src/server/sv_ccmds.c index 3ec3b8c7..1cc6cf3e 100644 --- a/src/server/sv_ccmds.c +++ b/src/server/sv_ccmds.c @@ -225,6 +225,71 @@ static void SV_MapRestart_f( void ) { /* ================== +SV_ConSayto_f +================== +*/ +static void SV_ConSayto_f(void) { + char *p; + char text[1024]; + client_t *cl; + char *rawname; + char name[MAX_NAME_LENGTH]; + char cleanName[MAX_NAME_LENGTH]; + client_t *saytocl; + int i; + + // make sure server is running + if ( !com_sv_running->integer ) { + Com_Printf( "Server is not running.\n" ); + return; + } + + if ( Cmd_Argc() < 3 ) { + Com_Printf ("Usage: sayto <player name> <text>\n"); + return; + } + + rawname = Cmd_Argv(1); + + //allowing special characters in the console + //with hex strings for player names + Com_FieldStringToPlayerName( name, MAX_NAME_LENGTH, rawname ); + + saytocl = NULL; + for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) { + if ( !cl->state ) { + continue; + } + Q_strncpyz( cleanName, cl->name, sizeof(cleanName) ); + Q_CleanStr( cleanName ); + + if ( !Q_stricmp( cleanName, name ) ) { + saytocl = cl; + break; + } + } + if( !saytocl ) + { + Com_Printf ("No such player name: %s.\n", name); + return; + } + + strcpy (text, "console_sayto: "); + p = Cmd_ArgsFrom(2); + + if ( *p == '"' ) { + p++; + p[strlen(p)-1] = 0; + } + + strcat(text, p); + + SV_SendServerCommand(saytocl, "chat \"%s\"", text); +} + + +/* +================== SV_Heartbeat_f Also called by SV_DropClient, SV_DirectConnect, and SV_SpawnServer |