From fea517607e117e5eb22ff8efaa022349ad0e1bab Mon Sep 17 00:00:00 2001 From: neon <> Date: Sun, 9 Sep 2018 01:48:11 +0200 Subject: [PATCH] NoSteamManager: autokick for non-Steamers with an Admin-SteamID --- NoSteamManager/scripting/NoSteamManager.sp | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/NoSteamManager/scripting/NoSteamManager.sp b/NoSteamManager/scripting/NoSteamManager.sp index 48c706a6..7803406b 100644 --- a/NoSteamManager/scripting/NoSteamManager.sp +++ b/NoSteamManager/scripting/NoSteamManager.sp @@ -10,6 +10,9 @@ ConVar g_hCvar_BlockAdmin; ConVar g_hCvar_BlockVoice; +/* DATABASE */ +Database g_hDatabase; + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -36,6 +39,17 @@ public void OnPluginStart() RegConsoleCmd("sm_steam", Command_DisplaySteamStats, "Shows the number of Steam and No-Steam players"); AutoExecConfig(); + + char sError[256]; + if (SQL_CheckConfig("sourcebans")) + { + g_hDatabase = SQL_Connect("sourcebans", true, sError, sizeof(sError)); + } + + if (g_hDatabase == null) + { + LogError("Could not connect to database: %s", sError); + } } //---------------------------------------------------------------------------------------------------- @@ -139,6 +153,10 @@ public Action OnClientPreAdminCheck(int client) LogMessage("%L was not authenticated with steam, denying admin.", client); NotifyPostAdminCheck(client); + char sQuery[512]; + Format(sQuery, sizeof(sQuery), "SELECT * from sb_admins WHERE authid = '%s'", sSteamID); + SQL_TQuery(g_hDatabase, TQueryCB, sQuery, GetClientUserId(client)); + return Plugin_Handled; } @@ -163,7 +181,23 @@ public void OnClientPostAdminCheck(int client) { LogMessage("%L was not authenticated with steam, muting client.", client); BaseComm_SetClientMute(client, true); - return; } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void TQueryCB(Handle owner, Handle rs, const char[] error, any data) +{ + int client = 0; + + if ((client = GetClientOfUserId(data)) == 0) + return; + + if (SQL_GetRowCount(rs) > 0) + { + LogMessage("%L tried to join with an Admin-SteamID while not being authentiated with steam.", client); + KickClient(client, "Trying to join with an Admin-SteamID while not being authentiated with steam."); + } } \ No newline at end of file