From c06337ee50f2a208d4cebbbd5647b366cd88b8e1 Mon Sep 17 00:00:00 2001 From: Rushaway Date: Sun, 19 Jan 2025 16:53:44 +0100 Subject: [PATCH] feat: mutes and gags sbpp support (#21) --- README.md | 29 ++++++++++++----- addons/sourcemod/scripting/ConnectAnnounce.sp | 32 +++++++++++++++++-- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 79eb04a..e472cec 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,25 @@ The plugin can be configured using the `connectannounce.cfg` file. Here are some ```plaintext // Enable or disable the plugin -sm_connectannounce_enable "1" +sm_connect_announce "1" -// Set the default join message -sm_connectannounce_default_message "Welcome to the server, {name}!" +// Storage type used for connect messages [sql, local] +sm_connect_announce_storage "sql" -// Enable or disable HLstatsX integration -sm_connectannounce_hlstatsx_enable "1" +// Add HLstatsX informations on player connection? +sm_connect_announce_hlstatsx "1" -// Set the HLstatsX database configuration name -sm_connectannounce_hlstatsx_db "hlstatsx" +// How many times should the plugin retry after a fail-to-run query? +sm_connect_announce_query_retry "5" + +// Formating returned bans count [0 = Count only 1 = Count only if > 0 | 2 = Count + Text] +sm_connect_announce_ban_format "0" + +// AuthID type used for connect messages [0 = Engine, 1 = Steam2, 2 = Steam3, 3 = Steam64] +sm_connect_announce_authid_type "1" + +// Set the HLstatsX database configuration name (Server game code used for hlstatsx) +sm_connect_announce_hlstatsx_table "css-ze" ``` **You can configured the player connect message like you want in** `addons/sourcemod/configs/connect_announce/settings.cfg` @@ -58,7 +67,11 @@ These variables can be used in `addons/sourcemod/configs/connect_announce/settin - `{COMMS}` - Number of bans. (SBPP only) -- `{STEAMID}` - Player identification provided by Steam AuthId_Steam2 format. +- `{MUTES}` - Number of mutes (SBPP only) + +- `{GAGS}` - Number of gags (SBPP only) + +- `{STEAMID}` - Player SteamID. [See cvar: `sm_connect_announce_authid_type`] - `{NAME}` - Player name diff --git a/addons/sourcemod/scripting/ConnectAnnounce.sp b/addons/sourcemod/scripting/ConnectAnnounce.sp index 92d84c0..ed8d522 100644 --- a/addons/sourcemod/scripting/ConnectAnnounce.sp +++ b/addons/sourcemod/scripting/ConnectAnnounce.sp @@ -72,6 +72,8 @@ bool g_bNative_KbRestrict = false; bool g_bSbChecker = false; bool g_bNative_SbChecker_Bans = false; bool g_bNative_SbChecker_Comms = false; +bool g_bNative_SbChecker_Mutes = false; +bool g_bNative_SbChecker_Gags = false; //---------------------------------------------------------------------------------------------------- // Purpose: @@ -81,7 +83,7 @@ public Plugin myinfo = name = "Connect Announce", author = "Neon + Botox + maxime1907 + .Rushaway", description = "Connect Announcer", - version = "2.3.10", + version = "2.3.11", url = "" } @@ -191,6 +193,8 @@ stock void VerifyNative_SbChecker() { g_bNative_SbChecker_Bans = g_bSbChecker && CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "SBPP_CheckerGetClientsBans") == FeatureStatus_Available; g_bNative_SbChecker_Comms = g_bSbChecker && CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "SBPP_CheckerGetClientsComms") == FeatureStatus_Available; + g_bNative_SbChecker_Mutes = g_bSbChecker && CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "SBPP_CheckerGetClientsMutes") == FeatureStatus_Available; + g_bNative_SbChecker_Gags = g_bSbChecker && CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "SBPP_CheckerGetClientsGags") == FeatureStatus_Available; } public void OnMapEnd() @@ -1138,8 +1142,6 @@ public void Announcer(int client, int iRank, bool sendToAll) ReplaceString(sFinalMessage, sizeof(sFinalMessage), "{BANS}", sBuffer); } - // Todo: When sbpp checker will support mute and gag separately add {MUTES} and {GAGS} - if (StrContains(sFinalMessage, "{COMMS}")) { char sBuffer[16]; @@ -1151,6 +1153,30 @@ public void Announcer(int client, int iRank, bool sendToAll) ReplaceString(sFinalMessage, sizeof(sFinalMessage), "{COMMS}", sBuffer); } + + if (StrContains(sFinalMessage, "{MUTES}")) + { + char sBuffer[16]; + if (g_bNative_SbChecker_Mutes) + { + int iMutes = SBPP_CheckerGetClientsMutes(client); + FormatBanCount(sBuffer, sizeof(sBuffer), iMutes, "Mutes"); + } + + ReplaceString(sFinalMessage, sizeof(sFinalMessage), "{MUTES}", sBuffer); + } + + if (StrContains(sFinalMessage, "{GAGS}")) + { + char sBuffer[16]; + if (g_bNative_SbChecker_Gags) + { + int iGags = SBPP_CheckerGetClientsGags(client); + FormatBanCount(sBuffer, sizeof(sBuffer), iGags, "Gags"); + } + + ReplaceString(sFinalMessage, sizeof(sFinalMessage), "{GAGS}", sBuffer); + } #endif if (StrContains(sFinalMessage, "{STEAMID}"))