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:
@@ -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