Add ChatFilter2, OverheadChat, EventGreeting and update several plugins

New plugins: ChatFilter2, OverheadChat, EventGreeting.

Updated: HostnameManager, Leader3 (chat and markers), NameFilter2 (plugin
and config), PlayerRankings_nohlstats (rank display modes), custom-chatcolors
(plugin and ccc.inc), Extend (sm_settimeleft).

Add shared includes the plugins build against: Break, ChatFilter2, Couch,
EventNotifier, TransmitManager, leader, ripext, unloze_playtime.
This commit is contained in:
2026-11-23 13:20:15 +00:00
parent 2dca39be8a
commit 3a52b1dfd1
25 changed files with 6209 additions and 175 deletions
+128 -76
View File
@@ -25,6 +25,7 @@ public Plugin myinfo =
//Handle tagForward;
//Handle applicationForward;
Handle messageForward;
Handle rewriteForward;
Handle preLoadedForward;
Handle loadedForward;
Handle configReloadedForward;
@@ -64,6 +65,11 @@ char g_msgName[128];
char g_msgSender[128];
char g_msgText[MAX_CHAT_LENGTH];
char g_msgFinal[255];
char g_msgTextRaw[MAX_CHAT_LENGTH]; // g_msgText before coloring, for CCC_OnChatMessageRewrite
char g_msgFinalRewritten[255];
bool g_msgIsAction;
int g_msgChatColor;
bool g_msgChatAlpha;
bool g_msgIsTeammate;
bool g_Ignored[(MAXPLAYERS + 1) * (MAXPLAYERS + 1)] = {false, ...};
@@ -140,6 +146,7 @@ public void OnPluginStart()
//tagForward = CreateGlobalForward("CCC_OnTagApplied", ET_Event, Param_Cell);
//applicationForward = CreateGlobalForward("CCC_OnColor", ET_Event, Param_Cell, Param_String, Param_Cell);
messageForward = CreateGlobalForward("CCC_OnChatMessage", ET_Event, Param_Cell, Param_Cell, Param_String);
rewriteForward = CreateGlobalForward("CCC_OnChatMessageRewrite", ET_Event, Param_Cell, Param_String, Param_Cell);
preLoadedForward = CreateGlobalForward("CCC_OnUserConfigPreLoaded", ET_Event, Param_Cell);
loadedForward = CreateGlobalForward("CCC_OnUserConfigLoaded", ET_Ignore, Param_Cell);
configReloadedForward = CreateGlobalForward("CCC_OnConfigReloaded", ET_Ignore);
@@ -2603,10 +2610,12 @@ public Action Hook_UserMessage(UserMsg msg_id, Handle bf, const int[] players, i
}
}
if (!g_msgAuthor || HasFlag(g_msgAuthor, Admin_Custom1))
{
CFormatColor(g_msgText, sizeof(g_msgText), g_msgAuthor);
}
strcopy(g_msgTextRaw, sizeof(g_msgTextRaw), g_msgText);
g_msgIsAction = bIsAction;
g_msgChatColor = xiChatColor;
g_msgChatAlpha = bChatAlpha;
ColorChatText(g_msgText, sizeof(g_msgText));
if (!bIsAction)
{
@@ -2662,34 +2671,6 @@ public Action Hook_UserMessage(UserMsg msg_id, Handle bf, const int[] players, i
Format(g_msgSender, sizeof(g_msgSender), "\x08%08X%s%s", xiTagColor, sAuthorTag, g_msgSender);
}
}
if (g_msgText[0] == '>' && (GetConVarInt(g_hGreenText) == 1 || (GetConVarInt(g_hGreenText) == 2 && CheckCommandAccess(g_msgAuthor, "sm_tag", ADMFLAG_CUSTOM1))))
{
Format(g_msgText, sizeof(g_msgText), "\x0714C800%s", g_msgText);
}
else if (xiChatColor == COLOR_NONE || g_bTagToggled[g_msgAuthor])
{
}
else if (xiChatColor == COLOR_TEAM)
{
Format(g_msgText, sizeof(g_msgText), "\x03%s", g_msgText);
}
else if (xiChatColor == COLOR_CGREEN)
{
Format(g_msgText, sizeof(g_msgText), "\x04%s", g_msgText);
}
else if (xiChatColor == COLOR_OLIVE)
{
Format(g_msgText, sizeof(g_msgText), "\x05%s", g_msgText);
}
else if (!bChatAlpha)
{
Format(g_msgText, sizeof(g_msgText), "\x07%06X%s", xiChatColor, g_msgText);
}
else
{
Format(g_msgText, sizeof(g_msgText), "\x08%08X%s", xiChatColor, g_msgText);
}
}
Format(g_msgFinal, sizeof(g_msgFinal), "%t", g_msgName, g_msgSender, g_msgText);
@@ -2697,6 +2678,94 @@ public Action Hook_UserMessage(UserMsg msg_id, Handle bf, const int[] players, i
return Plugin_Handled;
}
// Applies the author's chat text coloring, using the state Hook_UserMessage stored for this message
void ColorChatText(char[] text, int maxlen)
{
if (!g_msgAuthor || HasFlag(g_msgAuthor, Admin_Custom1))
{
CFormatColor(text, maxlen, g_msgAuthor);
}
if (g_msgIsAction)
return;
if (text[0] == '>' && (GetConVarInt(g_hGreenText) == 1 || (GetConVarInt(g_hGreenText) == 2 && CheckCommandAccess(g_msgAuthor, "sm_tag", ADMFLAG_CUSTOM1))))
{
Format(text, maxlen, "\x0714C800%s", text);
}
else if (g_msgChatColor == COLOR_NONE || g_bTagToggled[g_msgAuthor])
{
}
else if (g_msgChatColor == COLOR_TEAM)
{
Format(text, maxlen, "\x03%s", text);
}
else if (g_msgChatColor == COLOR_CGREEN)
{
Format(text, maxlen, "\x04%s", text);
}
else if (g_msgChatColor == COLOR_OLIVE)
{
Format(text, maxlen, "\x05%s", text);
}
else if (!g_msgChatAlpha)
{
Format(text, maxlen, "\x07%06X%s", g_msgChatColor, text);
}
else
{
Format(text, maxlen, "\x08%08X%s", g_msgChatColor, text);
}
}
// Lets plugins rewrite the raw message once; on success g_msgFinalRewritten holds the formatted line
bool BuildRewrittenMessage()
{
char sText[MAX_CHAT_LENGTH];
strcopy(sText, sizeof(sText), g_msgTextRaw);
Action result = Plugin_Continue;
Call_StartForward(rewriteForward);
Call_PushCell(g_msgAuthor);
Call_PushStringEx(sText, sizeof(sText), SM_PARAM_STRING_UTF8 | SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
Call_PushCell(sizeof(sText));
Call_Finish(result);
if (result != Plugin_Changed || StrEqual(sText, g_msgTextRaw))
return false;
TrimString(sText);
if (strlen(sText) == 0)
return false;
ColorChatText(sText, sizeof(sText));
Format(g_msgFinalRewritten, sizeof(g_msgFinalRewritten), "%t", g_msgName, g_msgSender, sText);
return true;
}
void SendSayText2(const int[] players, int playersNum, const char[] text)
{
Handle SayText2 = StartMessage("SayText2", players, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
if (GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
{
PbSetInt(SayText2, "ent_idx", g_msgAuthor);
PbSetBool(SayText2, "chat", g_msgIsChat);
PbSetString(SayText2, "text", text);
EndMessage();
}
else
{
BfWriteByte(SayText2, g_msgAuthor);
BfWriteByte(SayText2, g_msgIsChat);
BfWriteString(SayText2, text);
EndMessage();
}
}
public Action Event_PlayerSay(Handle event, const char[] name, bool dontBroadcast)
{
if (g_msgAuthor == -1 || GetClientOfUserId(GetEventInt(event, "userid")) != g_msgAuthor)
@@ -2709,54 +2778,40 @@ public Action Event_PlayerSay(Handle event, const char[] name, bool dontBroadcas
int[] players = new int[MaxClients + 1];
int playersNum = 0;
int[] rewritePlayers = new int[MaxClients + 1];
int rewritePlayersNum = 0;
int team = (g_msgIsTeammate && g_msgAuthor > 0) ? GetClientTeam(g_msgAuthor) : -1;
if (g_msgIsTeammate && g_msgAuthor > 0)
for (int client = 1; client <= MaxClients; client++)
{
int team = GetClientTeam(g_msgAuthor);
if (!IsClientInGame(client) || (team != -1 && GetClientTeam(client) != team))
continue;
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client) && GetClientTeam(client) == team)
{
if(!g_Ignored[client * (MAXPLAYERS + 1) + g_msgAuthor] && MessageForward(client, g_msgAuthor, g_msgText) )
players[playersNum++] = client;
}
}
}
else
{
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client))
{
if(!g_Ignored[client * (MAXPLAYERS + 1) + g_msgAuthor] && MessageForward(client, g_msgAuthor, g_msgText) )
players[playersNum++] = client;
}
}
if (g_Ignored[client * (MAXPLAYERS + 1) + g_msgAuthor])
continue;
Action result = MessageForward(client, g_msgAuthor, g_msgText);
if (result == Plugin_Changed)
rewritePlayers[rewritePlayersNum++] = client;
else if (result < Plugin_Handled)
players[playersNum++] = client;
}
if (!playersNum)
// viewers who asked for a rewrite see the normal line when no plugin rewrote it
if (rewritePlayersNum && !BuildRewrittenMessage())
{
g_msgAuthor = -1;
return Plugin_Handled;
for (int i = 0; i < rewritePlayersNum; i++)
players[playersNum++] = rewritePlayers[i];
rewritePlayersNum = 0;
}
Handle SayText2 = StartMessage("SayText2", players, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
if (playersNum)
SendSayText2(players, playersNum, g_msgFinal);
if (GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
{
PbSetInt(SayText2, "ent_idx", g_msgAuthor);
PbSetBool(SayText2, "chat", g_msgIsChat);
PbSetString(SayText2, "text", g_msgFinal);
EndMessage();
}
else
{
BfWriteByte(SayText2, g_msgAuthor);
BfWriteByte(SayText2, g_msgIsChat);
BfWriteString(SayText2, g_msgFinal);
EndMessage();
}
if (rewritePlayersNum)
SendSayText2(rewritePlayers, rewritePlayersNum, g_msgFinalRewritten);
g_msgAuthor = -1;
return Plugin_Handled;
@@ -2851,7 +2906,7 @@ stock bool ConfigForward(int client)
return true;
}
stock bool MessageForward(int client, int author, char[] message)
stock Action MessageForward(int client, int author, char[] message)
{
Action result = Plugin_Continue;
@@ -2861,10 +2916,7 @@ stock bool MessageForward(int client, int author, char[] message)
Call_PushString(message);
Call_Finish(result);
if (result >= Plugin_Handled)
return false;
return true;
return result;
}
public int Native_GetColor(Handle plugin, int numParams)
+15 -1
View File
@@ -137,10 +137,24 @@ native int CCC_ResetTag(int client);
* @param client Recieving client index
* @param author Author client index
* @param message Message
* @return Plugin_Handled to block message, Plugin_Continue to allow message
* @return Plugin_Handled to block message, Plugin_Changed to send this client the
* copy rewritten by CCC_OnChatMessageRewrite (or the normal message if
* nothing rewrote it), Plugin_Continue to allow message
*/
forward Action CCC_OnChatMessage(int client, int author, const char[] message);
/**
* Called at most once per chat message, and only if a recipient's CCC_OnChatMessage returned Plugin_Changed.
* The message is the raw text, after /me and auto-replace but before coloring.
* DO NOT START A NEW USERMESSAGE (i.e. PrintToChat, PrintToChatAll) WITHIN THIS FORWARD
*
* @param author Author client index
* @param message Message buffer to rewrite in place
* @param maxlen Size of the message buffer
* @return Plugin_Changed if the message was rewritten, Plugin_Continue otherwise
*/
forward Action CCC_OnChatMessageRewrite(int author, char[] message, int maxlen);
/**
* Called when a client's colors and tag are about to be loaded from the config file
* At this point, the client has NO COLORS