Skip to content

Commit f4dcc8d

Browse files
committed
Misc fixes
1 parent 4a4283c commit f4dcc8d

5 files changed

Lines changed: 23 additions & 3 deletions

File tree

Modules.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ Replacement for Cider ChatProcessors AllChat and DeadChat with some bonus featur
1717

1818
`sm_sayredirect_snoopflag` - Add staff members with the specified admin bit as recipients to MCP chat messages (Default z, empty to disable)
1919

20-
`sm_sayredirect_colorteamtag` - Set the (TEAM)-say prefix to use team color (1/0)
20+
`sm_sayredirect_colorteamtag` - Set the (TEAM)-say prefix to use team color (1/0)
21+
22+
`sm_sayredirect_forceteamname` - Force say_team messages to use the team name instead of the generic (TEAM) prefix (1/0)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Lastly there's the option `Ban On NewLine`, this option will automatically perma
4242
There is no way (that I know of) for a player to input new line characters into a chat message, and this seems to be only used by hack clients to disrupt chat flow (With the latest TF2 patch this should not longer be possible in that game anyways).
4343

4444
The config can be found at `addons/sourcemod/config/metachatprocessor.cfg`:
45-
```json
45+
```c
4646
"config"
4747
{
4848
"Compatibility"

scripting/MetaChatProcessor.sp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,12 @@ public Action OnCommand_SayCommand(int client, const char[] command, int argc) {
307307
BuildMessageFormat(g_currentMessage.senderflags, g_currentMessage.group, g_currentMessage.msg_name, sizeof(MessageData::msg_name));
308308
// fetch name and message
309309
GetClientName(client, g_currentMessage.sender_name, sizeof(MessageData::sender_name));
310-
GetCmdArgString(g_currentMessage.message, 128); //this uses the max length of the chat box, no cheating with console
310+
GetCmdArgString(g_currentMessage.message, sizeof(MessageData::message));
311+
if (argc==1 && g_currentMessage.message[0]=='"') {
312+
//higly probable that this message is sent from chat. argc==1 makes this check more robust than base game xD
313+
StripQuotes(g_currentMessage.message);
314+
}
315+
g_currentMessage.message[128]=0; //this uses the max length of the chat box, no cheating
311316

312317
// replace all control characters with a question mark. not possible through steam, but hacker can do
313318
int len = strlen(g_currentMessage.sender_name);

scripting/MetaChatProcessor/utilities.sp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void LoadCompatConfig() {
7878
if (kv.GetNum("Trim All Whitespaces")>0) g_sanitizeInput |= mcpInputTrimMBSpace;
7979
if (kv.GetNum("Ban On NewLine")>0) g_sanitizeInput |= mcpInputBanNewline;
8080
if (kv.GetNum("Strip Native Colorcodes")>0) g_sanitizeInput |= mcpInputStripColors;
81+
kv.GoBack();
8182
} else LogError("[MCP] 'Input Sanitizer' section missing from config");
8283
//transport method
8384
if (kv.GetDataType("Transport")==KvData_String) {

scripting/mcp-sayredirects.sp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ bool g_SnoopingEnabled;
2121
int g_AllChatMode;
2222
bool g_DeadChat;
2323
bool g_TeamTagColor;
24+
bool g_ForceTeamName;
2425

2526
static void HookAndLoadConVar(ConVar convar, ConVarChanged hook) {
2627
//I sometimes hate convars...
@@ -41,15 +42,18 @@ public void OnPluginStart() {
4142
ConVar cvar2 = CreateConVar("sm_sayredirect_allchat", "0", "Redirect team chat as follows: 0-Don't change; 1-Always to all; 2-Team 2 chat to all; 3-Team 3 chat to all", _, true, 0.0, true, 3.0);
4243
ConVar cvar3 = CreateConVar("sm_sayredirect_deadchat", "0", "Send messages from dead players to alive players", _, true, 0.0, true, 1.0);
4344
ConVar cvar4 = CreateConVar("sm_sayredirect_colorteamtag", "0", "Color the (TEAM) tag for say_team in team color", _, true, 0.0, true, 1.0);
45+
ConVar cvar5 = CreateConVar("sm_sayredirect_forceteamname", "0", "Force team say to use the team name instead of (TEAM)", _, true, 0.0, true, 1.0);
4446
AutoExecConfig(); //gen/load config
4547
HookAndLoadConVar(cvar1,OnConVarChanged_SnoopFlag);
4648
HookAndLoadConVar(cvar2,OnConVarChanged_AllChat);
4749
HookAndLoadConVar(cvar3,OnConVarChanged_DeadChat);
4850
HookAndLoadConVar(cvar4,OnConVarChanged_TeamTagColor);
51+
HookAndLoadConVar(cvar5,OnConVarChanged_ForceTeamName);
4952
delete cvar1;
5053
delete cvar2;
5154
delete cvar3;
5255
delete cvar4;
56+
delete cvar5;
5357
}
5458

5559
public void OnAllPluginsLoaded() {
@@ -69,12 +73,20 @@ public void OnConVarChanged_DeadChat(ConVar convar, const char[] oldValue, const
6973
public void OnConVarChanged_TeamTagColor(ConVar convar, const char[] oldValue, const char[] newValue) {
7074
g_TeamTagColor = convar.BoolValue;
7175
}
76+
public void OnConVarChanged_ForceTeamName(ConVar convar, const char[] oldValue, const char[] newValue) {
77+
g_ForceTeamName = convar.BoolValue;
78+
}
7279

7380
public Action OnMessage_Redirect(int& sender, ArrayList recipients, mcpSenderFlag& senderflags, mcpTargetGroup& targetgroup, mcpMessageOption& options, char[] targetgroupColor) {
7481
bool isTeamSay = mcpTargetTeam1 <= targetgroup <= mcpTargetTeamSender;
7582
bool isDeadChat = (senderflags & mcpSenderDead)!=mcpSenderNone;
7683
int fromTeam = sender ? GetClientTeam(sender) : 0;
7784

85+
//use team names instead of generic (TEAM) tag for say_team
86+
if (targetgroup == mcpTargetTeamSender && g_ForceTeamName && fromTeam) {
87+
targetgroup = view_as<mcpTargetGroup>(fromTeam);
88+
}
89+
7890
//true if this message stays withing the senders team
7991
bool checkTeam = isTeamSay;
8092
if (isTeamSay && (g_AllChatMode==1||(g_AllChatMode>1 && g_AllChatMode==fromTeam))) {

0 commit comments

Comments
 (0)