NoSteamManager: initial push.
This commit is contained in:
		
							parent
							
								
									bcf922ac02
								
							
						
					
					
						commit
						f4dfe66528
					
				
							
								
								
									
										153
									
								
								NoSteamManager/scripting/NoSteamManager.sp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								NoSteamManager/scripting/NoSteamManager.sp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,153 @@
 | 
			
		||||
#pragma semicolon 1
 | 
			
		||||
 | 
			
		||||
#include <sourcemod>
 | 
			
		||||
#include <basecomm>
 | 
			
		||||
#include <connect>
 | 
			
		||||
 | 
			
		||||
#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;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user