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:
@@ -14,6 +14,7 @@ bool g_bEngineCSGO;
|
||||
bool g_bHideCrown[MAXPLAYERS+1];
|
||||
bool g_bHideDialog[MAXPLAYERS+1];
|
||||
bool g_bProtection[MAXPLAYERS+1];
|
||||
bool g_bTitleSet[MAXPLAYERS+1];
|
||||
|
||||
/* COOKIES */
|
||||
Handle g_hCookie_HideCrown;
|
||||
@@ -26,6 +27,18 @@ ConVar g_hCVar_ProtectionMinimal1;
|
||||
ConVar g_hCVar_ProtectionMinimal2;
|
||||
ConVar g_hCVar_ProtectionMinimal3;
|
||||
ConVar g_hCVar_Grenade;
|
||||
ConVar g_hCVar_Display;
|
||||
ConVar g_hCVar_HudChannel;
|
||||
ConVar g_hCVar_HudX;
|
||||
ConVar g_hCVar_HudY;
|
||||
ConVar g_hCVar_Hostname;
|
||||
ConVar g_hCVar_HostIP;
|
||||
ConVar g_hCVar_HostPort;
|
||||
ConVar g_hCVar_Password;
|
||||
|
||||
/* STRINGS */
|
||||
char g_sRankTitle[MAXPLAYERS+1][128];
|
||||
char g_sTitleSent[MAXPLAYERS+1][128];
|
||||
|
||||
/* INTERGERS */
|
||||
int g_iDialogLevel = 100000;
|
||||
@@ -72,8 +85,17 @@ public void OnPluginStart()
|
||||
g_hCVar_ProtectionMinimal2 = CreateConVar("sm_topdefenders_minimal_2", "30", "", FCVAR_NONE, true, 1.0, true, 64.0);
|
||||
g_hCVar_ProtectionMinimal3 = CreateConVar("sm_topdefenders_minimal_3", "45", "", FCVAR_NONE, true, 1.0, true, 64.0);
|
||||
g_hCVar_Grenade = CreateConVar("sm_topdefenders_grenade", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||
g_hCVar_Display = CreateConVar("sm_topdefenders_display", "2", "Rank display: 0 off, 1 dialog, 2 hudtext, 3 scoreboard title (set sm_hostname_send_to_clients 0 so HostnameManager doesn't overwrite it)", FCVAR_NONE, true, 0.0, true, 3.0);
|
||||
g_hCVar_HudChannel = CreateConVar("sm_topdefenders_hud_channel", "5", "Hudtext channel for the rank display (0-5)", FCVAR_NONE, true, 0.0, true, 5.0);
|
||||
g_hCVar_HudX = CreateConVar("sm_topdefenders_hud_x", "0.01", "Hudtext x position for the rank display (-1 centres)", FCVAR_NONE, true, -1.0, true, 1.0);
|
||||
g_hCVar_HudY = CreateConVar("sm_topdefenders_hud_y", "0.01", "Hudtext y position for the rank display (-1 centres)", FCVAR_NONE, true, -1.0, true, 1.0);
|
||||
AutoExecConfig(true);
|
||||
|
||||
g_hCVar_Hostname = FindConVar("hostname");
|
||||
g_hCVar_HostIP = FindConVar("hostip");
|
||||
g_hCVar_HostPort = FindConVar("hostport");
|
||||
g_hCVar_Password = FindConVar("sv_password");
|
||||
|
||||
g_hCookie_HideCrown = RegClientCookie("topdefenders_hidecrown", "", CookieAccess_Private);
|
||||
g_hCookie_HideDialog = RegClientCookie("topdefenders_hidedialog", "", CookieAccess_Private);
|
||||
g_hCookie_Protection = RegClientCookie("topdefenders_protection", "", CookieAccess_Private);
|
||||
@@ -95,6 +117,14 @@ public void OnPluginStart()
|
||||
SetCookieMenuItem(MenuHandler_CookieMenu, 0, "Player Rankings");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose: Hand everyone showing a rank title the real hostname back.
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginEnd()
|
||||
{
|
||||
ResetAllTitles();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@@ -288,11 +318,21 @@ public void OnClientCookiesCached(int client)
|
||||
g_bProtection[client] = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientPutInServer(int client)
|
||||
{
|
||||
g_bTitleSet[client] = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_bTitleSet[client] = false;
|
||||
|
||||
g_iPlayerDamage[client] = 0;
|
||||
g_iPlayerDamageHits[client] = 0;
|
||||
g_iPlayerDamageFrom1K[client] = 0;
|
||||
@@ -350,9 +390,25 @@ public Action UpdateScoreboard(Handle timer)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action UpdateDialog(Handle timer)
|
||||
{
|
||||
if (g_bEngineCSGO || g_iDialogLevel <= 0)
|
||||
int iDisplay = g_hCVar_Display.IntValue;
|
||||
|
||||
if (iDisplay != 3 || g_iDialogLevel <= 0)
|
||||
ResetAllTitles();
|
||||
|
||||
if (g_bEngineCSGO || g_iDialogLevel <= 0 || iDisplay <= 0)
|
||||
return;
|
||||
|
||||
// Hudtext (held for 1s) and the scoreboard title only need a refresh every 0.5s, the dialog keeps the 0.1s rate.
|
||||
static int iHudTick;
|
||||
if (iDisplay >= 2 && (iHudTick++ % 5) != 0)
|
||||
return;
|
||||
|
||||
if (iDisplay == 3)
|
||||
{
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
g_sRankTitle[client][0] = '\0';
|
||||
}
|
||||
|
||||
int iSortedList[MAXPLAYERS+1][2];
|
||||
int iSortedCount;
|
||||
|
||||
@@ -368,16 +424,28 @@ public Action UpdateDialog(Handle timer)
|
||||
|
||||
SortCustom2D(iSortedList, iSortedCount, SortRankingsList);
|
||||
|
||||
char sBuffer[128];
|
||||
|
||||
for (int rank = 0; rank < iSortedCount; rank++)
|
||||
{
|
||||
switch(rank)
|
||||
{
|
||||
case(0): SendDialog(iSortedList[rank][0], "#%d (D: %d | P: -%d)", g_iDialogLevel, 1, rank + 1, iSortedList[rank][1], iSortedList[rank][1] - iSortedList[rank + 1][1]);
|
||||
case(1): SendDialog(iSortedList[rank][0], "#%d (D: %d | N: +%d)", g_iDialogLevel, 1, rank + 1, iSortedList[rank][1], iSortedList[rank - 1][1] - iSortedList[rank][1]);
|
||||
default: SendDialog(iSortedList[rank][0], "#%d (D: %d | N: +%d | F: +%d)", g_iDialogLevel, 1, rank + 1, iSortedList[rank][1], iSortedList[rank - 1][1] - iSortedList[rank][1], iSortedList[0][1] - iSortedList[rank][1]);
|
||||
case(0): Format(sBuffer, sizeof(sBuffer), "#%d (D: %d | P: -%d)", rank + 1, iSortedList[rank][1], iSortedList[rank][1] - iSortedList[rank + 1][1]);
|
||||
case(1): Format(sBuffer, sizeof(sBuffer), "#%d (D: %d | N: +%d)", rank + 1, iSortedList[rank][1], iSortedList[rank - 1][1] - iSortedList[rank][1]);
|
||||
default: Format(sBuffer, sizeof(sBuffer), "#%d (D: %d | N: +%d | F: +%d)", rank + 1, iSortedList[rank][1], iSortedList[rank - 1][1] - iSortedList[rank][1], iSortedList[0][1] - iSortedList[rank][1]);
|
||||
}
|
||||
|
||||
if (iDisplay == 1)
|
||||
SendDialog(iSortedList[rank][0], "%s", g_iDialogLevel, 1, sBuffer);
|
||||
else if (iDisplay == 2)
|
||||
SendRankHud(iSortedList[rank][0], sBuffer);
|
||||
else
|
||||
Format(g_sRankTitle[iSortedList[rank][0]], sizeof(g_sRankTitle[]), "[UNLOZE] Pos. %s", sBuffer);
|
||||
}
|
||||
|
||||
if (iDisplay == 3)
|
||||
UpdateTitles();
|
||||
|
||||
g_iDialogLevel--;
|
||||
}
|
||||
|
||||
@@ -1035,6 +1103,151 @@ void SendDialog(int client, const char[] text, const int level, const int time,
|
||||
delete kv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose: Rank line as hudtext. ShowHudText on a fixed channel keeps SourceMod's auto channel
|
||||
// picking (sync huds, channel -1) off it while it refreshes.
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void SendRankHud(int client, const char[] text)
|
||||
{
|
||||
int channel = g_hCVar_HudChannel.IntValue;
|
||||
|
||||
SetHudTextParams(g_hCVar_HudX.FloatValue, g_hCVar_HudY.FloatValue, 1.0, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
|
||||
|
||||
if (!g_bHideDialog[client])
|
||||
{
|
||||
ShowHudText(client, channel, "%s", text);
|
||||
}
|
||||
|
||||
for (int spec = 1; spec <= MaxClients; spec++)
|
||||
{
|
||||
if (!IsClientInGame(spec) || !IsClientObserver(spec) || g_bHideDialog[spec])
|
||||
continue;
|
||||
|
||||
int specMode = GetClientSpectatorMode(spec);
|
||||
int specTarget = GetClientSpectatorTarget(spec);
|
||||
|
||||
if ((specMode == SPECMODE_FIRSTPERSON || specMode == SPECMODE_THIRDPERSON) && specTarget == client)
|
||||
{
|
||||
ShowHudText(spec, channel, "%s", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose: Rank line as the scoreboard title. Unranked spectators see the title of the player they
|
||||
// watch in first or third person, everyone else gets the real hostname back.
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void UpdateTitles()
|
||||
{
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!IsClientInGame(client) || IsFakeClient(client))
|
||||
continue;
|
||||
|
||||
int source = client;
|
||||
|
||||
if (!g_sRankTitle[client][0] && IsClientObserver(client))
|
||||
{
|
||||
int specMode = GetClientSpectatorMode(client);
|
||||
int specTarget = GetClientSpectatorTarget(client);
|
||||
|
||||
if ((specMode == SPECMODE_FIRSTPERSON || specMode == SPECMODE_THIRDPERSON) && specTarget >= 1 && specTarget <= MaxClients)
|
||||
source = specTarget;
|
||||
}
|
||||
|
||||
if (g_bHideDialog[client] || !g_sRankTitle[source][0])
|
||||
ResetTitle(client);
|
||||
else
|
||||
SetTitle(client, g_sRankTitle[source]);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose: Only sends when the title changes.
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void SetTitle(int client, const char[] title)
|
||||
{
|
||||
if (g_bTitleSet[client] && strcmp(g_sTitleSent[client], title, true) == 0)
|
||||
return;
|
||||
|
||||
SendClientHostname(client, title);
|
||||
|
||||
strcopy(g_sTitleSent[client], sizeof(g_sTitleSent[]), title);
|
||||
g_bTitleSet[client] = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void ResetTitle(int client)
|
||||
{
|
||||
if (!g_bTitleSet[client])
|
||||
return;
|
||||
|
||||
g_bTitleSet[client] = false;
|
||||
|
||||
if (!IsClientInGame(client))
|
||||
return;
|
||||
|
||||
char sHostname[128];
|
||||
g_hCVar_Hostname.GetString(sHostname, sizeof(sHostname));
|
||||
|
||||
SendClientHostname(client, sHostname);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void ResetAllTitles()
|
||||
{
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
ResetTitle(client);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose: Copied from HostnameManager. 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 the client so it never reaches server-side listeners, and fill every field so
|
||||
// other client listeners (mumble, abuse report, steam share) see the values they got on connect.
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void SendClientHostname(int client, const char[] hostname)
|
||||
{
|
||||
Event hEvent = CreateEvent("server_spawn", true);
|
||||
if (hEvent == null)
|
||||
return;
|
||||
|
||||
int iIP = g_hCVar_HostIP.IntValue;
|
||||
int iPort = g_hCVar_HostPort.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_hCVar_Password.GetString(sPassword, sizeof(sPassword));
|
||||
|
||||
hEvent.SetString("hostname", hostname);
|
||||
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');
|
||||
|
||||
hEvent.FireToClient(client);
|
||||
|
||||
// FireToClient does not free the event.
|
||||
hEvent.Cancel();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user