29
29
30
30
#include <sourcemod>
31
31
32
- #define VERSION " 1.8.2 "
32
+ #define VERSION " 1.8.3 "
33
33
#define LISTBANS_USAGE " sm_listbans <#userid|name> - Lists a user's prior bans from Sourcebans"
34
34
#define LISTCOMMS_USAGE " sm_listcomms <#userid|name> - Lists a user's prior comms from Sourcebans"
35
35
#define INVALID_TARGET - 1
36
36
#define Prefix " \x04 [SourceBans++]\x01 "
37
37
38
+ bool g_bLate = false ;
38
39
bool g_bPrintCheckOnConnect = true ;
40
+
39
41
char g_DatabasePrefix [10 ] = " sb" ;
42
+
40
43
SMCParser g_ConfigParser ;
41
44
Database g_DB ;
42
45
43
46
int g_iBanCounts [MAXPLAYERS + 1 ];
44
- int g_iCommsCounts [MAXPLAYERS + 1 ];
45
-
47
+ int g_iMuteCounts [MAXPLAYERS + 1 ];
48
+ int g_iGagCounts [ MAXPLAYERS + 1 ];
46
49
47
50
public Plugin myinfo =
48
51
{
@@ -64,6 +67,11 @@ public void OnPluginStart()
64
67
RegAdminCmd (" sb_reload" , OnReloadCmd , ADMFLAG_RCON , " Reload sourcebans config and ban reason menu options" );
65
68
66
69
Database .Connect (OnDatabaseConnected , " sourcebans" );
70
+
71
+ if (g_bLate )
72
+ {
73
+ LateLoading ();
74
+ }
67
75
}
68
76
69
77
public void OnMapStart ()
@@ -91,6 +99,10 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
91
99
92
100
CreateNative (" SBPP_CheckerGetClientsBans" , Native_SBCheckerGetClientsBans );
93
101
CreateNative (" SBPP_CheckerGetClientsComms" , Native_SBCheckerGetClientsComms );
102
+ CreateNative (" SBPP_CheckerGetClientsMutes" , Native_SBCheckerGetClientsMutes );
103
+ CreateNative (" SBPP_CheckerGetClientsGags" , Native_SBCheckerGetClientsGags );
104
+
105
+ g_bLate = late ;
94
106
95
107
return APLRes_Success ;
96
108
}
@@ -104,7 +116,19 @@ public int Native_SBCheckerGetClientsBans(Handle plugin, int numParams)
104
116
public int Native_SBCheckerGetClientsComms (Handle plugin , int numParams )
105
117
{
106
118
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 ];
108
132
}
109
133
110
134
public void OnClientAuthorized (int client , const char [] auth )
@@ -118,32 +142,46 @@ public void OnClientAuthorized(int client, const char[] auth)
118
142
119
143
char query [512 ], ip [30 ];
120
144
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
+
122
159
g_DB .Query (OnConnectBanCheck , query , GetClientUserId (client ), DBPrio_Low );
123
160
}
124
161
125
162
public void OnConnectBanCheck (Database db , DBResultSet results , const char [] error , any userid )
126
163
{
127
164
int client = GetClientOfUserId (userid );
128
- int steamIdBanCount = 0 ;
129
165
if (! client || results == null || ! results .FetchRow ())
130
166
return ;
131
167
132
- steamIdBanCount = results .FetchInt (0 );
168
+ // SteamID bans
169
+ g_iBanCounts [client ] = results .FetchInt (0 );
133
170
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 );
139
174
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 );
144
182
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 ] ;
147
185
148
186
if (! g_bPrintCheckOnConnect )
149
187
return ;
@@ -604,4 +642,17 @@ public SMCResult ReadConfig_KeyValue(SMCParser smc, const char[] key, const char
604
642
public SMCResult ReadConfig_EndSection (SMCParser smc )
605
643
{
606
644
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
+ }
607
658
}
0 commit comments