Skip to content

Commit

Permalink
feat: mutes and gags sbpp support (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rushaway authored Jan 19, 2025
1 parent 261f945 commit c06337e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 11 deletions.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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

Expand Down
32 changes: 29 additions & 3 deletions addons/sourcemod/scripting/ConnectAnnounce.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 = ""
}

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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];
Expand All @@ -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}"))
Expand Down

0 comments on commit c06337e

Please sign in to comment.