diff --git a/game/addons/sourcemod/scripting/include/sourcebanschecker.inc b/game/addons/sourcemod/scripting/include/sourcebanschecker.inc index a67c17e0..363dc992 100644 --- a/game/addons/sourcemod/scripting/include/sourcebanschecker.inc +++ b/game/addons/sourcemod/scripting/include/sourcebanschecker.inc @@ -1,4 +1,4 @@ -// ************************************************************************* +// ************************************************************************* // This file is part of SourceBans++. // // Copyright (C) 2014-2023 SourceBans++ Dev Team @@ -53,7 +53,7 @@ public void __pl_sourcebanschecker_SetNTVOptional() * Get the number of bans of a client. * * @param iClient The client index of who you want to get the number of bans. - * @return The number of bans of the client. + * @return The number of bans of the client, or -1 if not yet available. *********************************************************/ native int SBPP_CheckerGetClientsBans(int iClient); @@ -62,6 +62,14 @@ native int SBPP_CheckerGetClientsBans(int iClient); * Get the number of comms bans of a client. * * @param iClient The client index of who you want to get the number of comms bans. - * @return The number of comms bans of the client. + * @return The number of comms bans of the client, or -1 if not yet available. *********************************************************/ native int SBPP_CheckerGetClientsComms(int iClient); + +/********************************************************** + * Called when the ban counts for a client are checked. + * Use the other natives to retrieve values. + * + * @param iClient The client index that was checked. + **********************************************************/ +forward void SBPP_CheckerClientBanCheckPost(int iClient); \ No newline at end of file diff --git a/game/addons/sourcemod/scripting/sbpp_checker.sp b/game/addons/sourcemod/scripting/sbpp_checker.sp index d786e9e3..38550ab4 100644 --- a/game/addons/sourcemod/scripting/sbpp_checker.sp +++ b/game/addons/sourcemod/scripting/sbpp_checker.sp @@ -29,7 +29,7 @@ #include -#define VERSION "1.8.0" +#define VERSION "1.8.1" #define LISTBANS_USAGE "sm_listbans <#userid|name> - Lists a user's prior bans from Sourcebans" #define LISTCOMMS_USAGE "sm_listcomms <#userid|name> - Lists a user's prior comms from Sourcebans" #define INVALID_TARGET -1 @@ -39,8 +39,9 @@ char g_DatabasePrefix[10] = "sb"; SMCParser g_ConfigParser; Database g_DB; -int g_iBanCounts[MAXPLAYERS + 1]; -int g_iCommsCounts[MAXPLAYERS + 1]; +int g_iBanCounts[MAXPLAYERS + 1] = {-1, ...}; +int g_iCommsCounts[MAXPLAYERS + 1] = {-1, ...}; +GlobalForward g_fwdClientBanCheckPost; public Plugin myinfo = @@ -61,7 +62,7 @@ public void OnPluginStart() RegAdminCmd("sm_listbans", OnListSourceBansCmd, ADMFLAG_GENERIC, LISTBANS_USAGE); RegAdminCmd("sm_listcomms", OnListSourceCommsCmd, ADMFLAG_GENERIC, LISTCOMMS_USAGE); RegAdminCmd("sb_reload", OnReloadCmd, ADMFLAG_RCON, "Reload sourcebans config and ban reason menu options"); - + Database.Connect(OnDatabaseConnected, "sourcebans"); } @@ -91,6 +92,8 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max CreateNative("SBPP_CheckerGetClientsBans", Native_SBCheckerGetClientsBans); CreateNative("SBPP_CheckerGetClientsComms", Native_SBCheckerGetClientsComms); + g_fwdClientBanCheckPost = CreateGlobalForward("SBPP_CheckerClientBanCheckPost", ET_Ignore, Param_Cell); + return APLRes_Success; } @@ -106,6 +109,12 @@ public int Native_SBCheckerGetClientsComms(Handle plugin, int numParams) return g_iCommsCounts[client]; } +public void OnClientDisconnect_Post(int client) +{ + g_iBanCounts[client] = -1; + g_iCommsCounts[client] = -1; +} + public void OnClientAuthorized(int client, const char[] auth) { if (g_DB == null) @@ -145,6 +154,10 @@ public void OnConnectBanCheck(Database db, DBResultSet results, const char[] err else if ( bancount ) { PrintToBanAdmins("%s%t", Prefix, "Ban Warning", client, bancount, ((bancount > 1 || bancount == 0) ? "s":"")); } + + Call_StartForward(g_fwdClientBanCheckPost); + Call_PushCell(client); + Call_Finish(); } public Action OnListSourceBansCmd(int client, int args)