2929
3030#include <sourcemod>
3131
32- #define VERSION " 1.8.2 "
32+ #define VERSION " 1.8.3 "
3333#define LISTBANS_USAGE " sm_listbans <#userid|name> - Lists a user's prior bans from Sourcebans"
3434#define LISTCOMMS_USAGE " sm_listcomms <#userid|name> - Lists a user's prior comms from Sourcebans"
3535#define INVALID_TARGET - 1
3636#define Prefix " \x04 [SourceBans++]\x01 "
3737
38+ bool g_bLate = false ;
3839bool g_bPrintCheckOnConnect = true ;
40+
3941char g_DatabasePrefix [10 ] = " sb" ;
42+
4043SMCParser g_ConfigParser ;
4144Database g_DB ;
4245
4346int g_iBanCounts [MAXPLAYERS + 1 ];
44- int g_iCommsCounts [MAXPLAYERS + 1 ];
45-
47+ int g_iMuteCounts [MAXPLAYERS + 1 ];
48+ int g_iGagCounts [ MAXPLAYERS + 1 ];
4649
4750public Plugin myinfo =
4851{
@@ -64,6 +67,11 @@ public void OnPluginStart()
6467 RegAdminCmd (" sb_reload" , OnReloadCmd , ADMFLAG_RCON , " Reload sourcebans config and ban reason menu options" );
6568
6669 Database .Connect (OnDatabaseConnected , " sourcebans" );
70+
71+ if (g_bLate )
72+ {
73+ LateLoading ();
74+ }
6775}
6876
6977public void OnMapStart ()
@@ -91,6 +99,10 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
9199
92100 CreateNative (" SBPP_CheckerGetClientsBans" , Native_SBCheckerGetClientsBans );
93101 CreateNative (" SBPP_CheckerGetClientsComms" , Native_SBCheckerGetClientsComms );
102+ CreateNative (" SBPP_CheckerGetClientsMutes" , Native_SBCheckerGetClientsMutes );
103+ CreateNative (" SBPP_CheckerGetClientsGags" , Native_SBCheckerGetClientsGags );
104+
105+ g_bLate = late ;
94106
95107 return APLRes_Success ;
96108}
@@ -104,7 +116,19 @@ public int Native_SBCheckerGetClientsBans(Handle plugin, int numParams)
104116public int Native_SBCheckerGetClientsComms (Handle plugin , int numParams )
105117{
106118 int client = GetNativeCell (1 );
107- return g_iCommsCounts [client ];
119+ return g_iMuteCounts [client ] + g_iGagCounts [client ];
120+ }
121+
122+ public int Native_SBCheckerGetClientsMutes (Handle plugin , int numParams )
123+ {
124+ int client = GetNativeCell (1 );
125+ return g_iMuteCounts [client ];
126+ }
127+
128+ public int Native_SBCheckerGetClientsGags (Handle plugin , int numParams )
129+ {
130+ int client = GetNativeCell (1 );
131+ return g_iGagCounts [client ];
108132}
109133
110134public void OnClientAuthorized (int client , const char [] auth )
@@ -118,32 +142,46 @@ public void OnClientAuthorized(int client, const char[] auth)
118142
119143 char query [512 ], ip [30 ];
120144 GetClientIP (client , ip , sizeof (ip ));
121- FormatEx (query , sizeof (query ), " SELECT COUNT(bid) FROM %s _bans WHERE (type = 0 AND authid LIKE 'STEAM_%% :%s ') UNION ALL SELECT COUNT(bid) FROM %s _bans WHERE (type = 1 AND ip = '%s ') UNION ALL SELECT COUNT(bid) FROM %s _comms WHERE authid LIKE 'STEAM_%% :%s '" , g_DatabasePrefix , auth [8 ], g_DatabasePrefix , ip , g_DatabasePrefix , auth [8 ]);
145+ FormatEx (query , sizeof (query ),
146+ " SELECT COUNT(bid) FROM %s _bans WHERE (type = 0 AND authid LIKE 'STEAM_%% :%s ') \
147+ UNION ALL \
148+ SELECT COUNT(bid) FROM %s _bans WHERE (type = 1 AND ip = '%s ') \
149+ UNION ALL \
150+ SELECT COUNT(bid) FROM %s _comms WHERE authid LIKE 'STEAM_%% :%s ' AND type = 1 \
151+ UNION ALL \
152+ SELECT COUNT(bid) FROM %s _comms WHERE authid LIKE 'STEAM_%% :%s ' AND type = 2" ,
153+ g_DatabasePrefix , auth [8 ],
154+ g_DatabasePrefix , ip ,
155+ g_DatabasePrefix , auth [8 ],
156+ g_DatabasePrefix , auth [8 ]
157+ );
158+
122159 g_DB .Query (OnConnectBanCheck , query , GetClientUserId (client ), DBPrio_Low );
123160}
124161
125162public void OnConnectBanCheck (Database db , DBResultSet results , const char [] error , any userid )
126163{
127164 int client = GetClientOfUserId (userid );
128- int steamIdBanCount = 0 ;
129165 if (! client || results == null || ! results .FetchRow ())
130166 return ;
131167
132- steamIdBanCount = results .FetchInt (0 );
168+ // SteamID bans
169+ g_iBanCounts [client ] = results .FetchInt (0 );
133170
134- int ipBanCount = 0 ;
135- if (results .FetchRow ()) {
136- ipBanCount = results .FetchInt (0 );
137- }
138- int bancount = steamIdBanCount + ipBanCount ;
171+ // IP bans
172+ if (results .FetchRow ())
173+ g_iBanCounts [client ] += results .FetchInt (0 );
139174
140- int commcount = 0 ;
141- if (results .FetchRow ()) {
142- commcount = results .FetchInt (0 );
143- }
175+ // Mutes (type = 1)
176+ if (results .FetchRow ())
177+ g_iMuteCounts [client ] = results .FetchInt (0 );
178+
179+ // Gags (type = 2)
180+ if (results .FetchRow ())
181+ g_iGagCounts [client ] = results .FetchInt (0 );
144182
145- g_iBanCounts [client ] = bancount ;
146- g_iCommsCounts [client ] = commcount ;
183+ int bancount = g_iBanCounts [client ];
184+ int commcount = g_iMuteCounts [client ] + g_iGagCounts [ client ] ;
147185
148186 if (! g_bPrintCheckOnConnect )
149187 return ;
@@ -604,4 +642,17 @@ public SMCResult ReadConfig_KeyValue(SMCParser smc, const char[] key, const char
604642public SMCResult ReadConfig_EndSection (SMCParser smc )
605643{
606644 return SMCParse_Continue ;
645+ }
646+
647+ stock void LateLoading ()
648+ {
649+ char sSteam32ID [64 ];
650+ for (int i = 1 ; i <= MaxClients ; i ++ )
651+ {
652+ if (! IsClientConnected (i ) || ! IsClientInGame (i ) || IsFakeClient (i ) || ! IsClientAuthorized (i ))
653+ continue ;
654+
655+ GetClientAuthId (i , AuthId_Steam2 , sSteam32ID , sizeof (sSteam32ID ));
656+ OnClientAuthorized (i , sSteam32ID );
657+ }
607658}
0 commit comments