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:
@@ -15,6 +15,7 @@
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <AFKManager>
|
||||
#include <ChatFilter2>
|
||||
#define REQUIRE_PLUGIN
|
||||
|
||||
#pragma newdecls required
|
||||
@@ -98,7 +99,15 @@ bool g_bLeaderWhitelisted[MAXPLAYERS + 1];
|
||||
bool g_bForceLeaderMute;
|
||||
bool g_bForceMuted[MAXPLAYERS + 1];
|
||||
|
||||
// Our own copy of ZR's zombie flag. ZR_IsClientZombie throws on dead clients and team is
|
||||
// unreliable at death (ZR round-end balancing puts living zombies on CT), so player_death
|
||||
// reads this instead. Set on infection, cleared on spawn/cure/disconnect like ZR's own flag.
|
||||
bool g_bZombie[MAXPLAYERS + 1];
|
||||
|
||||
bool g_bAFKManager;
|
||||
bool g_bChatFilter2;
|
||||
// ChatFilter2 safe chat per client, kept by ChatFilter2_OnSafeChatChanged so transmit hooks need no native call
|
||||
bool g_bSafeChat[MAXPLAYERS + 1];
|
||||
bool g_bWorldTextBroken;
|
||||
|
||||
GlobalForward g_fwdOnLeaderAdded;
|
||||
@@ -227,6 +236,13 @@ public void OnPluginStart()
|
||||
AddMultiTargetFilter("@!leaders", Filter_NotLeaders, "everyone but the Leaders", false);
|
||||
AddMultiTargetFilter("@leader", Filter_Leader, "the Primary Leader", false);
|
||||
AddMultiTargetFilter("@!leader", Filter_NotLeader, "everyone but the Primary Leader", false);
|
||||
|
||||
// Late load: pick up zombies infected before we were running.
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (IsClientInGame(i))
|
||||
g_bZombie[i] = IsLivingZombie(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPluginEnd()
|
||||
@@ -240,18 +256,24 @@ public void OnPluginEnd()
|
||||
public void OnAllPluginsLoaded()
|
||||
{
|
||||
g_bAFKManager = LibraryExists("AFKManager");
|
||||
if (LibraryExists("ChatFilter2"))
|
||||
Chat_OnChatFilter2Added();
|
||||
}
|
||||
|
||||
public void OnLibraryAdded(const char[] name)
|
||||
{
|
||||
if (StrEqual(name, "AFKManager"))
|
||||
g_bAFKManager = true;
|
||||
else if (StrEqual(name, "ChatFilter2"))
|
||||
Chat_OnChatFilter2Added();
|
||||
}
|
||||
|
||||
public void OnLibraryRemoved(const char[] name)
|
||||
{
|
||||
if (StrEqual(name, "AFKManager"))
|
||||
g_bAFKManager = false;
|
||||
else if (StrEqual(name, "ChatFilter2"))
|
||||
Chat_OnChatFilter2Removed();
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
@@ -357,6 +379,9 @@ public void OnClientDisconnect(int client)
|
||||
BaseComm_SetClientMute(client, false);
|
||||
g_bForceMuted[client] = false;
|
||||
}
|
||||
|
||||
g_bZombie[client] = false;
|
||||
g_bSafeChat[client] = false;
|
||||
}
|
||||
|
||||
public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
|
||||
@@ -368,6 +393,12 @@ public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
|
||||
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
int userid = event.GetInt("userid");
|
||||
|
||||
// Everyone spawns human (ZR clears its flag here too); infection after spawn sets it again.
|
||||
int client = GetClientOfUserId(userid);
|
||||
if (client > 0)
|
||||
g_bZombie[client] = false;
|
||||
|
||||
// Attach effects slightly late: at spawn time ZR state and position may not be final.
|
||||
CreateTimer(0.3, Timer_ResumeEffects, userid, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
@@ -386,9 +417,11 @@ public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast
|
||||
if (client <= 0)
|
||||
return;
|
||||
|
||||
// Toll and announce only for an active (human) leader falling; an infected leader dying later as a zombie stays quiet.
|
||||
// ZR_IsClientHuman throws on dead clients, so go by team: zombified leaders sit on T.
|
||||
bool diedAsHuman = GetClientTeam(client) == CS_TEAM_CT;
|
||||
// Toll and announce only for an active (human) leader falling. A leader who was infected,
|
||||
// or picked as mother zombie, and then dies as a zombie stays quiet. ZR's fake infection
|
||||
// death fires before ZR_OnClientInfected, so g_bZombie is still false for that one and the
|
||||
// toll marks the infection.
|
||||
bool diedAsHuman = !g_bZombie[client];
|
||||
|
||||
if (IsLeader(client) && diedAsHuman)
|
||||
{
|
||||
@@ -421,6 +454,8 @@ public void Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast)
|
||||
|
||||
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
||||
{
|
||||
g_bZombie[client] = true;
|
||||
|
||||
char verb[80];
|
||||
if (attacker > 0 && attacker <= MaxClients && attacker != client)
|
||||
Format(verb, sizeof(verb), "has been infected by \x04%N\x01", attacker);
|
||||
@@ -432,6 +467,8 @@ public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, boo
|
||||
|
||||
public void ZR_OnClientHumanPost(int client, bool respawn, bool protect)
|
||||
{
|
||||
g_bZombie[client] = false;
|
||||
|
||||
if (IsEffectsActive(client))
|
||||
Effects_Resume(client);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,29 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// ChatFilter2 (optional): safe chat players get censored marker titles.
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ChatFilter2_OnSafeChatChanged(int client, bool enabled)
|
||||
{
|
||||
g_bSafeChat[client] = enabled;
|
||||
}
|
||||
|
||||
void Chat_OnChatFilter2Added()
|
||||
{
|
||||
g_bChatFilter2 = true;
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
g_bSafeChat[i] = IsClientInGame(i) && ChatFilter2_IsSafeChatEnabled(i);
|
||||
}
|
||||
|
||||
// Censored copies stay up but nobody counts as safe chat any more, so everyone sees the raw text.
|
||||
void Chat_OnChatFilter2Removed()
|
||||
{
|
||||
g_bChatFilter2 = false;
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
g_bSafeChat[i] = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Force-mute: while any leader is talking, mute everyone without admin access.
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Leader3 markers: unloze_ping prop_dynamic markers with point_worldtext titles.
|
||||
// The ArrayList is the authoritative store; entities are respawned from it every round.
|
||||
// A title that ChatFilter2 censors gets a second text entity; SetTransmit shows the censored
|
||||
// one to safe chat players and the raw one to everyone else.
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
enum struct Marker
|
||||
@@ -10,9 +12,11 @@ enum struct Marker
|
||||
int skin;
|
||||
float pos[3];
|
||||
char title[128];
|
||||
char censoredTitle[128]; // empty when ChatFilter2 is missing or the title is clean
|
||||
float placedAt;
|
||||
int propRef;
|
||||
int textRef;
|
||||
int censoredTextRef;
|
||||
}
|
||||
|
||||
ArrayList g_alMarkers;
|
||||
@@ -97,9 +101,11 @@ void Marker_Place(int client, int skin)
|
||||
marker.skin = skin;
|
||||
marker.pos = pos;
|
||||
marker.title[0] = '\0';
|
||||
marker.censoredTitle[0] = '\0';
|
||||
marker.placedAt = GetGameTime();
|
||||
marker.propRef = INVALID_ENT_REFERENCE;
|
||||
marker.textRef = INVALID_ENT_REFERENCE;
|
||||
marker.censoredTextRef = INVALID_ENT_REFERENCE;
|
||||
|
||||
int idx = g_alMarkers.PushArray(marker);
|
||||
SpawnMarkerProp(idx);
|
||||
@@ -136,7 +142,10 @@ bool Marker_GetTitle(int client, int skin, char[] buf, int maxlen)
|
||||
if (marker.title[0] == '\0')
|
||||
return false;
|
||||
|
||||
strcopy(buf, maxlen, marker.title);
|
||||
if (g_bSafeChat[client] && marker.censoredTitle[0] != '\0')
|
||||
strcopy(buf, maxlen, marker.censoredTitle);
|
||||
else
|
||||
strcopy(buf, maxlen, marker.title);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -190,6 +199,17 @@ void UppercaseAllLowerTitle(char[] text)
|
||||
}
|
||||
}
|
||||
|
||||
void Marker_CensorTitle(Marker marker)
|
||||
{
|
||||
marker.censoredTitle[0] = '\0';
|
||||
if (!g_bChatFilter2 || marker.title[0] == '\0')
|
||||
return;
|
||||
|
||||
strcopy(marker.censoredTitle, sizeof(marker.censoredTitle), marker.title);
|
||||
if (!ChatFilter2_CensorText(marker.censoredTitle, sizeof(marker.censoredTitle)))
|
||||
marker.censoredTitle[0] = '\0';
|
||||
}
|
||||
|
||||
void Marker_SetTitle(int client, const char[] text)
|
||||
{
|
||||
int userid = GetClientUserId(client);
|
||||
@@ -217,6 +237,7 @@ void Marker_SetTitle(int client, const char[] text)
|
||||
g_alMarkers.GetArray(lastIdx, marker);
|
||||
strcopy(marker.title, sizeof(marker.title), text);
|
||||
UppercaseAllLowerTitle(marker.title);
|
||||
Marker_CensorTitle(marker);
|
||||
g_alMarkers.SetArray(lastIdx, marker);
|
||||
Marker_UpdateText(lastIdx);
|
||||
|
||||
@@ -228,7 +249,23 @@ void Marker_SetTitle(int client, const char[] text)
|
||||
PrintToChat(client, "%sTitle removed from your \x04%s\x01 marker.", PREFIX, skinName);
|
||||
return;
|
||||
}
|
||||
PrintToChatAll("%s\x04%N\x01 marked \x04%s\x01: \x04%s", PREFIX, client, skinName, marker.title);
|
||||
|
||||
if (marker.censoredTitle[0] == '\0')
|
||||
{
|
||||
PrintToChatAll("%s\x04%N\x01 marked \x04%s\x01: \x04%s", PREFIX, client, skinName, marker.title);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (!IsClientInGame(i))
|
||||
continue;
|
||||
|
||||
if (g_bSafeChat[i])
|
||||
PrintToChat(i, "%s\x04%N\x01 marked \x04%s\x01: \x04%s", PREFIX, client, skinName, marker.censoredTitle);
|
||||
else
|
||||
PrintToChat(i, "%s\x04%N\x01 marked \x04%s\x01: \x04%s", PREFIX, client, skinName, marker.title);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@@ -266,18 +303,41 @@ void SpawnMarkerText(int idx)
|
||||
if (marker.title[0] == '\0' || g_bWorldTextBroken)
|
||||
return;
|
||||
|
||||
float pos[3];
|
||||
ComputeMarkerTextPos(marker, pos);
|
||||
|
||||
int ent = SpawnWorldText(marker.title, pos);
|
||||
if (ent == -1)
|
||||
return;
|
||||
marker.textRef = EntIndexToEntRef(ent);
|
||||
|
||||
// The raw text is hidden from safe chat players even if the censored copy fails to spawn.
|
||||
if (marker.censoredTitle[0] != '\0')
|
||||
{
|
||||
SDKHook(ent, SDKHook_SetTransmit, Hook_TitleRawTransmit);
|
||||
|
||||
int censored = SpawnWorldText(marker.censoredTitle, pos);
|
||||
if (censored != -1)
|
||||
{
|
||||
SDKHook(censored, SDKHook_SetTransmit, Hook_TitleCensoredTransmit);
|
||||
marker.censoredTextRef = EntIndexToEntRef(censored);
|
||||
}
|
||||
}
|
||||
|
||||
g_alMarkers.SetArray(idx, marker);
|
||||
}
|
||||
|
||||
int SpawnWorldText(const char[] text, const float pos[3])
|
||||
{
|
||||
int ent = CreateEntityByName("point_worldtext");
|
||||
if (ent == -1)
|
||||
{
|
||||
// Engine build without point_worldtext: titles stay chat-only for this map.
|
||||
g_bWorldTextBroken = true;
|
||||
LogMessage("point_worldtext could not be created; marker titles will not render in the world.");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
char text[192];
|
||||
Format(text, sizeof(text), "%s", marker.title);
|
||||
|
||||
DispatchKeyValue(ent, "message", text);
|
||||
DispatchKeyValue(ent, "font", "10");
|
||||
DispatchKeyValue(ent, "textsize", "12");
|
||||
@@ -285,13 +345,18 @@ void SpawnMarkerText(int idx)
|
||||
DispatchKeyValue(ent, "orientation", "1");
|
||||
DispatchKeyValue(ent, "rainbow", "1");
|
||||
DispatchSpawn(ent);
|
||||
|
||||
float pos[3];
|
||||
ComputeMarkerTextPos(marker, pos);
|
||||
TeleportEntity(ent, pos, NULL_VECTOR, NULL_VECTOR);
|
||||
return ent;
|
||||
}
|
||||
|
||||
marker.textRef = EntIndexToEntRef(ent);
|
||||
g_alMarkers.SetArray(idx, marker);
|
||||
public Action Hook_TitleRawTransmit(int ent, int client)
|
||||
{
|
||||
return g_bSafeChat[client] ? Plugin_Handled : Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action Hook_TitleCensoredTransmit(int ent, int client)
|
||||
{
|
||||
return g_bSafeChat[client] ? Plugin_Continue : Plugin_Handled;
|
||||
}
|
||||
|
||||
void ComputeMarkerTextPos(const Marker marker, float pos[3])
|
||||
@@ -339,33 +404,42 @@ void Marker_UpdateText(int idx)
|
||||
Marker marker;
|
||||
g_alMarkers.GetArray(idx, marker);
|
||||
|
||||
if (marker.title[0] == '\0')
|
||||
int ent = LiveEntRef(marker.textRef, "point_worldtext");
|
||||
int censored = LiveEntRef(marker.censoredTextRef, "point_worldtext");
|
||||
|
||||
// No title, a lost entity, or a title that gained or lost its censored copy: respawn.
|
||||
// The last case is rare, and respawning keeps the transmit hooks in step with the entities.
|
||||
if (marker.title[0] == '\0' || ent == -1 || (marker.censoredTitle[0] != '\0') != (censored != -1))
|
||||
{
|
||||
KillEntRef(marker.textRef, "point_worldtext");
|
||||
KillEntRef(marker.censoredTextRef, "point_worldtext");
|
||||
marker.textRef = INVALID_ENT_REFERENCE;
|
||||
marker.censoredTextRef = INVALID_ENT_REFERENCE;
|
||||
g_alMarkers.SetArray(idx, marker);
|
||||
return;
|
||||
}
|
||||
|
||||
int ent = LiveEntRef(marker.textRef, "point_worldtext");
|
||||
if (ent == -1)
|
||||
{
|
||||
SpawnMarkerText(idx);
|
||||
return;
|
||||
}
|
||||
|
||||
SetVariantString(marker.title);
|
||||
AcceptEntityInput(ent, "SetText");
|
||||
|
||||
float pos[3];
|
||||
ComputeMarkerTextPos(marker, pos);
|
||||
|
||||
SetVariantString(marker.title);
|
||||
AcceptEntityInput(ent, "SetText");
|
||||
TeleportEntity(ent, pos, NULL_VECTOR, NULL_VECTOR);
|
||||
|
||||
if (censored != -1)
|
||||
{
|
||||
SetVariantString(marker.censoredTitle);
|
||||
AcceptEntityInput(censored, "SetText");
|
||||
TeleportEntity(censored, pos, NULL_VECTOR, NULL_VECTOR);
|
||||
}
|
||||
}
|
||||
|
||||
void Marker_KillEnts(Marker marker)
|
||||
{
|
||||
KillEntRef(marker.propRef, "prop_dynamic");
|
||||
KillEntRef(marker.textRef, "point_worldtext");
|
||||
KillEntRef(marker.censoredTextRef, "point_worldtext");
|
||||
}
|
||||
|
||||
void KillEntRef(int ref, const char[] expectedClass)
|
||||
@@ -400,6 +474,7 @@ void Markers_OnRoundStart()
|
||||
g_alMarkers.GetArray(i, marker);
|
||||
marker.propRef = INVALID_ENT_REFERENCE;
|
||||
marker.textRef = INVALID_ENT_REFERENCE;
|
||||
marker.censoredTextRef = INVALID_ENT_REFERENCE;
|
||||
g_alMarkers.SetArray(i, marker);
|
||||
|
||||
SpawnMarkerProp(i);
|
||||
|
||||
Reference in New Issue
Block a user