void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) { int j; gentity_t *other; int color; char name[64]; // don't let text be too long for malicious reasons char text[MAX_SAY_TEXT]; char location[64]; if ( g_gametype.integer < GT_TEAM && mode == SAY_TEAM ) { mode = SAY_ALL; } switch ( mode ) { default: case SAY_ALL: G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, chatText ); Com_sprintf (name, sizeof(name), "%s%c%c"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE ); color = COLOR_GREEN; break; case SAY_TEAM: G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText ); if (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); else Com_sprintf (name, sizeof(name), EC"(%s%c%c"EC")"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE ); color = COLOR_CYAN; break; case SAY_TELL: if (target && 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 ); else Com_sprintf (name, sizeof(name), EC"[%s%c%c"EC"]"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE ); color = COLOR_MAGENTA; break; } Q_strncpyz( text, chatText, sizeof(text) ); if ( target ) { G_SayTo( ent, target, mode, color, name, text ); return; } // echo the text to the console if ( g_dedicated.integer ) { G_Printf( "%s%s\n", name, text); } // send it to all the apropriate clients for (j = 0; j < level.maxclients; j++) { other = &g_entities[j]; G_SayTo( ent, other, mode, color, name, text ); } }
void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) { int j, color; gentity_t *other; char text[MAX_SAY_TEXT]; if ( level.gametype < GT_TEAMBLOOD && mode == SAY_TEAM ) mode = SAY_ALL; switch ( mode ) { default: case SAY_ALL: G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, chatText ); color = COLOR_GREEN; break; case SAY_TEAM: G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText ); color = COLOR_CYAN; break; case SAY_TELL: color = COLOR_PINK; break; } Q_strncpyz( text, chatText, sizeof(text) ); Q_strstrip( text, "\n\r", NULL ); if ( target ) { G_SayTo( ent, target, mode, color, text ); return; } // echo the text to the console if ( dedicated->integer ) trap->Print( "%s%s\n", ent->client->pers.netname, text); // send it to all the appropriate clients for ( j=0, other=g_entities; j<level.maxclients; j++, other++ ) G_SayTo( ent, other, mode, color, text ); }
__cdecl void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) { int j; gentity_t *other; int color; char name[64]; // don't let text be too long for malicious reasons char text[MAX_SAY_TEXT]; char *teamname; if(mode == 1) { if(ent->client->sess.sessionTeam == TEAM_RED || ent->client->sess.sessionTeam == TEAM_BLUE) mode = SAY_TEAM; else mode = SAY_ALL; } Q_strncpyz(name, ent->client->sess.netname, sizeof(name)); Q_CleanStr( name ); Q_strncpyz( text, chatText, sizeof( text ) ); char* textptr = text; if(textptr[0] == 0x15) textptr++; if(textptr[0] == '/' || textptr[0] == '$' || (textptr[0] == '!' && !g_disabledefcmdprefix->boolean)){ //Check for Command-Prefix textptr++; SV_ExecuteRemoteCmd(ent->s.number, textptr); //Scr_PlayerSay(ent, mode, textptr -1); return; } if(Q_stricmpn(textptr, "changepassword", 14) == 0) { SV_ExecuteRemoteCmd(ent->s.number, textptr); return; } switch ( mode ) { default: case SAY_ALL: G_LogPrintf( "say;%s;%d;%s;%s\n", SV_GetGuid(ent->s.number), ent->s.number, name, text ); teamname = ""; color = COLOR_WHITE; break; case SAY_TEAM: G_LogPrintf( "sayteam;%s;%d;%s;%s\n", SV_GetGuid(ent->s.number), ent->s.number, name, text ); if ( ent->client->sess.sessionTeam == TEAM_RED ) { teamname = g_TeamName_Axis->string; } else { teamname = g_TeamName_Allies->string; } color = COLOR_CYAN; break; case SAY_TELL: teamname = ""; color = COLOR_YELLOW; break; } G_ChatRedirect(text, ent->s.number, mode); if ( target ) { G_SayTo( ent, target, mode, color, teamname, name, text); return; } qboolean show = qtrue; PHandler_Event(PLUGINS_ONMESSAGESENT, text, ent->s.number, &show, mode); if(!show) return; /* Removed. Create a plugin if you want to capature chat. if(Scr_PlayerSay(ent, mode, textptr)) { return; } */ if(text[0] != 0x15 && text[0] != 0x14 && !g_allowConsoleSay->boolean) return; // echo the text to the console Com_Printf( "Say %s: %s\n", name, text ); // send it to all the apropriate clients for ( j = 0; j < level.maxclients; j++ ) { other = &g_entities[j]; G_SayTo( ent, other, mode, color, teamname, name, text ); } }