From f4dfe66528f166cd480466550d600da6e966a2b2 Mon Sep 17 00:00:00 2001 From: zaCade Date: Sat, 24 Mar 2018 17:20:48 +0100 Subject: [PATCH] NoSteamManager: initial push. --- NoSteamManager/scripting/NoSteamManager.sp | 153 +++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 NoSteamManager/scripting/NoSteamManager.sp diff --git a/NoSteamManager/scripting/NoSteamManager.sp b/NoSteamManager/scripting/NoSteamManager.sp new file mode 100644 index 00000000..cdfcc79c --- /dev/null +++ b/NoSteamManager/scripting/NoSteamManager.sp @@ -0,0 +1,153 @@ +#pragma semicolon 1 + +#include +#include +#include + +#pragma newdecls required + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Plugin myinfo = +{ + name = "NoSteamManager", + author = "zaCade", + description = "Manage No-Steam clients, denying admin access, ect.", + version = "1.0.0" +}; + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnPluginStart() +{ + AddMultiTargetFilter("@steam", Filter_Steam, "Steam Players", false); + AddMultiTargetFilter("@nosteam", Filter_NoSteam, "No-Steam Players", false); + + RegConsoleCmd("sm_nosteam", Command_DisplaySteamStats, "Shows the number of Steam and No-Steam players"); + RegConsoleCmd("sm_steam", Command_DisplaySteamStats, "Shows the number of Steam and No-Steam players"); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnPluginEnd() +{ + RemoveMultiTargetFilter("@steam", Filter_Steam); + RemoveMultiTargetFilter("@nosteam", Filter_NoSteam); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action Command_DisplaySteamStats(int client, int args) +{ + char aBuf[1024]; + char aBuf2[MAX_NAME_LENGTH]; + + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i) && !IsFakeClient(i)) + { + char sSteamID[32]; + GetClientAuthId(i, AuthId_Steam2, sSteamID, sizeof(sSteamID)); + + if(!SteamClientAuthenticated(sSteamID)) + { + GetClientName(i, aBuf2, sizeof(aBuf2)); + StrCat(aBuf, sizeof(aBuf), aBuf2); + StrCat(aBuf, sizeof(aBuf), ", "); + } + } + } + + if(strlen(aBuf)) + { + aBuf[strlen(aBuf) - 2] = 0; + ReplyToCommand(client, "[SM] No-Steam clients online: %s", aBuf); + } + else + ReplyToCommand(client, "[SM] No-Steam clients online: none"); + + return Plugin_Handled; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public bool Filter_Steam(const char[] sPattern, Handle hClients) +{ + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i) && !IsFakeClient(i)) + { + char sSteamID[32]; + GetClientAuthId(i, AuthId_Steam2, sSteamID, sizeof(sSteamID)); + + if(SteamClientAuthenticated(sSteamID)) + PushArrayCell(hClients, i); + } + } + return true; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public bool Filter_NoSteam(const char[] sPattern, Handle hClients) +{ + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i) && !IsFakeClient(i)) + { + char sSteamID[32]; + GetClientAuthId(i, AuthId_Steam2, sSteamID, sizeof(sSteamID)); + + if(!SteamClientAuthenticated(sSteamID)) + PushArrayCell(hClients, i); + } + } + return true; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action OnClientPreAdminCheck(int client) +{ + if (IsFakeClient(client) || IsClientSourceTV(client)) + return Plugin_Continue; + + char sSteamID[32]; + GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID)); + + if(!SteamClientAuthenticated(sSteamID)) + { + LogMessage("%L was not authenticated with steam, denying admin.", client); + NotifyPostAdminCheck(client); + + return Plugin_Handled; + } + + return Plugin_Continue; +} + +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientPostAdminCheck(int client) +{ + if (IsFakeClient(client) || IsClientSourceTV(client)) + return; + + char sSteamID[32]; + GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID)); + + if(!SteamClientAuthenticated(sSteamID)) + { + LogMessage("%L was not authenticated with steam, muting client.", client); + BaseComm_SetClientMute(client, true); + + return; + } +}