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
+206 -22
View File
@@ -3,18 +3,26 @@
#include <sourcemod>
#undef REQUIRE_PLUGIN
#include <Couch>
#include <HappyHour>
#include <StageDisplay>
#define REQUIRE_PLUGIN
#pragma newdecls required
ConVar g_cvInfoMessage;
ConVar g_cvHostname;
ConVar g_cvFormattedHostname;
ConVar g_cvHostIP;
ConVar g_cvHostPort;
ConVar g_cvPassword;
ConVar g_cvMaxLength;
ConVar g_cvSendToClients;
// Dropped in this order while the hostname is longer than sm_hostname_max_length.
char g_sFoldOrder[][] = { "LagCompensation", "NoSteam" };
bool g_bCouchLoaded;
bool g_bHHLoaded;
bool g_bNemesis;
bool g_bSDLoaded;
@@ -34,7 +42,12 @@ public Plugin myinfo =
public void OnPluginStart()
{
g_cvHostname = FindConVar("hostname");
g_cvFormattedHostname = CreateConVar("sm_hostname_format", "{HH}UNLOZE | {GM} | LagCompensation | NoSteam{SD}", "HH = HappyHour, , GM = GameMode, SD = StageDisplay");
g_cvHostIP = FindConVar("hostip");
g_cvHostPort = FindConVar("hostport");
g_cvPassword = FindConVar("sv_password");
g_cvFormattedHostname = CreateConVar("sm_hostname_format", "{HH}UNLOZE | {GM} | LagCompensation | NoSteam{SD}", "HH = HappyHour, GM = GameMode (Nemesis Zombie Escape > Couch Escape > Zombie Escape), SD = StageDisplay");
g_cvMaxLength = CreateConVar("sm_hostname_max_length", "63", "Fold LagCompensation, then NoSteam, out of the hostname while it is longer than this many bytes (the server browser shows at most 63)", 0, true, 1.0, true, 127.0);
g_cvSendToClients = CreateConVar("sm_hostname_send_to_clients", "1", "Send the new hostname to connected clients so their scoreboard updates without a reconnect", 0, true, 0.0, true, 1.0);
CreateTimer(60.0, TimerRepeat, INVALID_HANDLE, TIMER_REPEAT);
@@ -46,17 +59,17 @@ public void OnPluginStart()
//----------------------------------------------------------------------------------------------------
public void OnAllPluginsLoaded()
{
g_bCouchLoaded = LibraryExists("Couch");
g_bHHLoaded = LibraryExists("HappyHour");
g_bSDLoaded = LibraryExists("StageDisplay");
}
if((g_cvInfoMessage = FindConVar("sm_info_message_file")) == INVALID_HANDLE)
SetFailState("Failed to find sm_info_message_file cvar.");
char sFile[PLATFORM_MAX_PATH];
g_cvInfoMessage.GetString(sFile, sizeof(sFile));
OnClassesPathChange(g_cvInfoMessage, "", sFile);
HookConVarChange(g_cvInfoMessage, OnClassesPathChange);
//----------------------------------------------------------------------------------------------------
// Purpose: server.cfg resets the hostname every map, and this also runs on a late load.
//----------------------------------------------------------------------------------------------------
public void OnConfigsExecuted()
{
RefreshHostname();
}
//----------------------------------------------------------------------------------------------------
@@ -64,6 +77,9 @@ public void OnAllPluginsLoaded()
//----------------------------------------------------------------------------------------------------
public void OnLibraryAdded(const char[] sName)
{
if (strcmp(sName, "Couch", false) == 0)
g_bCouchLoaded = true;
if (strcmp(sName, "HappyHour", false) == 0)
g_bHHLoaded = true;
@@ -76,6 +92,13 @@ public void OnLibraryAdded(const char[] sName)
//----------------------------------------------------------------------------------------------------
public void OnLibraryRemoved(const char[] sName)
{
// Unloading Couch doesn't fire Couch_OnCouchRemoved, so drop the couch game mode here.
if (strcmp(sName, "Couch", false) == 0)
{
g_bCouchLoaded = false;
RefreshHostname();
}
if (strcmp(sName, "HappyHour", false) == 0)
g_bHHLoaded = false;
@@ -130,28 +153,189 @@ public void RefreshHostname()
else
ReplaceString(sFormattedHostname, sizeof(sFormattedHostname), "{SD}", "", true);
if (g_bNemesis)
if (IsNemesisMap())
ReplaceString(sFormattedHostname, sizeof(sFormattedHostname), "{GM}", "Nemesis Zombie Escape", true);
else if (IsCouchPresent())
ReplaceString(sFormattedHostname, sizeof(sFormattedHostname), "{GM}", "Couch Escape", true);
else
ReplaceString(sFormattedHostname, sizeof(sFormattedHostname), "{GM}", "Zombie Escape", true);
int iLength = strlen(sFormattedHostname);
if(iLength > 55) //if too long trim lagcomp
ReplaceString(sFormattedHostname, sizeof(sFormattedHostname), "LagCompensation | ", "", true);
TidyHostname(sFormattedHostname);
for (int i = 0; i < sizeof(g_sFoldOrder) && strlen(sFormattedHostname) > g_cvMaxLength.IntValue; i++)
{
ReplaceString(sFormattedHostname, sizeof(sFormattedHostname), g_sFoldOrder[i], "", true);
TidyHostname(sFormattedHostname);
}
char sCurrentHostname[128];
g_cvHostname.GetString(sCurrentHostname, sizeof(sCurrentHostname));
if (strcmp(sFormattedHostname, sCurrentHostname, true) == 0)
return;
g_cvHostname.SetString(sFormattedHostname, false, false);
if (g_cvSendToClients.BoolValue)
SendHostname(sFormattedHostname);
}
//----------------------------------------------------------------------------------------------------
// Purpose: The scoreboard only reads the hostname from server_spawn, which the client's engine fires
// locally from svc_ServerInfo on connect. Send a copy straight to each client so it never
// reaches server-side listeners, and fill every field so other client listeners
// (mumble, abuse report, steam share) see the same values they got on connect.
//----------------------------------------------------------------------------------------------------
void SendHostname(const char[] sHostname)
{
Event hEvent = CreateEvent("server_spawn", true);
if (hEvent == null)
return;
int iIP = g_cvHostIP.IntValue;
int iPort = g_cvHostPort.IntValue;
char sAddress[32];
Format(sAddress, sizeof(sAddress), "%d.%d.%d.%d:%d", (iIP >>> 24) & 0xFF, (iIP >>> 16) & 0xFF, (iIP >>> 8) & 0xFF, iIP & 0xFF, iPort);
char sGame[32];
GetGameFolderName(sGame, sizeof(sGame));
char sMap[PLATFORM_MAX_PATH];
GetCurrentMap(sMap, sizeof(sMap));
char sPassword[64];
g_cvPassword.GetString(sPassword, sizeof(sPassword));
hEvent.SetString("hostname", sHostname);
hEvent.SetString("address", sAddress);
hEvent.SetInt("ip", iIP);
hEvent.SetInt("port", iPort);
hEvent.SetString("game", sGame);
hEvent.SetString("mapname", sMap);
hEvent.SetInt("maxplayers", MaxClients);
hEvent.SetString("os", "LINUX");
hEvent.SetBool("dedicated", IsDedicatedServer());
hEvent.SetBool("password", sPassword[0] != '\0');
for (int client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client) || IsFakeClient(client))
continue;
hEvent.FireToClient(client);
}
// FireToClient does not free the event.
hEvent.Cancel();
}
//----------------------------------------------------------------------------------------------------
// Purpose: The couch entity is purged on every round restart and respawned at round start, so a
// remembered placement counts too, otherwise the hostname would flicker each round.
//----------------------------------------------------------------------------------------------------
bool IsCouchPresent()
{
if (!g_bCouchLoaded)
return false;
return Couch_GetCouch() != -1 || Couch_IsPlaced();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClassesPathChange(ConVar convar, const char[] oldValue, const char[] newValue)
public void Couch_OnCouchSpawned(int couch)
{
char sFile[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sFile, sizeof(sFile), "%s", newValue);
RefreshHostname();
}
if (StrContains(sFile, "nemesis", false) != -1)
g_bNemesis = true;
else
g_bNemesis = false;
//----------------------------------------------------------------------------------------------------
// Purpose: Couch_Remove fires this before it forgets the placement, so wait a frame.
//----------------------------------------------------------------------------------------------------
public void Couch_OnCouchRemoved()
{
RequestFrame(Frame_RefreshHostname);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void Frame_RefreshHostname(any data)
{
RefreshHostname();
}
//----------------------------------------------------------------------------------------------------
// Purpose: Empty tokens and folded tags leave separators and spaces behind.
//----------------------------------------------------------------------------------------------------
void TidyHostname(char[] sText)
{
DropEmptySeparators(sText);
CollapseSpaces(sText);
}
//----------------------------------------------------------------------------------------------------
// Purpose: {SD} brings its own " | ", so a format like "{GM} | {SD}" leaves "| |" with a stage and a
// trailing "|" without one. Drop any separator with nothing but spaces on one side.
//----------------------------------------------------------------------------------------------------
void DropEmptySeparators(char[] sText)
{
int iOut = 0;
for (int i = 0; sText[i] != '\0'; i++)
{
if (sText[i] == '|')
{
int iLast = iOut;
while (iLast > 0 && sText[iLast - 1] == ' ')
iLast--;
if (iLast == 0 || sText[iLast - 1] == '|')
continue;
}
sText[iOut++] = sText[i];
}
while (iOut > 0 && (sText[iOut - 1] == ' ' || sText[iOut - 1] == '|'))
iOut--;
sText[iOut] = '\0';
}
//----------------------------------------------------------------------------------------------------
// Purpose: Tokens that resolve to nothing leave their surrounding spaces behind, so squash any run
// of spaces down to one and trim the ends.
//----------------------------------------------------------------------------------------------------
void CollapseSpaces(char[] sText)
{
int iOut = 0;
for (int i = 0; sText[i] != '\0'; i++)
{
if (sText[i] == ' ' && (iOut == 0 || sText[iOut - 1] == ' '))
continue;
sText[iOut++] = sText[i];
}
if (iOut > 0 && sText[iOut - 1] == ' ')
iOut--;
sText[iOut] = '\0';
}
//----------------------------------------------------------------------------------------------------
// Purpose: Looked up every refresh because not every server runs the InfoMessage plugin, and it
// may load after us.
//----------------------------------------------------------------------------------------------------
bool IsNemesisMap()
{
ConVar cvInfoMessage = FindConVar("sm_info_message_file");
if (cvInfoMessage == null)
return false;
char sFile[PLATFORM_MAX_PATH];
cvInfoMessage.GetString(sFile, sizeof(sFile));
return StrContains(sFile, "nemesis", false) != -1;
}