NoSteamManager: Allow unvalid steamid's to pass.

a steamid like STEAM_ID_PENDING was causing people to get kicked,
because if someone was already connected with a steamid it would count
as a double.
This commit is contained in:
zaCade 2018-07-20 15:52:46 +02:00
parent 73f2909a34
commit fad99bc1f2

View File

@ -3,6 +3,7 @@
#include <sourcemod> #include <sourcemod>
#include <basecomm> #include <basecomm>
#include <connect> #include <connect>
#include <regex>
#pragma newdecls required #pragma newdecls required
@ -11,6 +12,9 @@ ConVar g_hCvar_BlockAdmin;
ConVar g_hCvar_BlockVoice; ConVar g_hCvar_BlockVoice;
ConVar g_hCvar_BlockSpoof; ConVar g_hCvar_BlockSpoof;
/* REGEX */
Regex g_hReg_ValidateSteamID;
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -27,6 +31,8 @@ public Plugin myinfo =
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnPluginStart() public void OnPluginStart()
{ {
g_hReg_ValidateSteamID = CompileRegex("[^STEAM_[01]:[01]:\\d{1,10}]");
g_hCvar_BlockAdmin = CreateConVar("sm_nosteam_block_admin", "1", "Should people marked as nosteam be blocked from admin?", FCVAR_NONE, true, 0.0, true, 1.0); g_hCvar_BlockAdmin = CreateConVar("sm_nosteam_block_admin", "1", "Should people marked as nosteam be blocked from admin?", FCVAR_NONE, true, 0.0, true, 1.0);
g_hCvar_BlockVoice = CreateConVar("sm_nosteam_block_voice", "1", "Should people marked as nosteam be blocked from voice?", FCVAR_NONE, true, 0.0, true, 1.0); g_hCvar_BlockVoice = CreateConVar("sm_nosteam_block_voice", "1", "Should people marked as nosteam be blocked from voice?", FCVAR_NONE, true, 0.0, true, 1.0);
g_hCvar_BlockSpoof = CreateConVar("sm_nosteam_block_spoof", "1", "Block nosteam people being able to spoof steamids.", FCVAR_NONE, true, 0.0, true, 1.0); g_hCvar_BlockSpoof = CreateConVar("sm_nosteam_block_spoof", "1", "Block nosteam people being able to spoof steamids.", FCVAR_NONE, true, 0.0, true, 1.0);
@ -184,6 +190,9 @@ public void OnClientPutInServer(int client)
char sSteamID[32]; char sSteamID[32];
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID)); GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
if(MatchRegex(g_hReg_ValidateSteamID, sSteamID) <= 0)
return;
for(int player = 1; player <= MaxClients; player++) for(int player = 1; player <= MaxClients; player++)
{ {
if(client == player || !IsClientConnected(player)) if(client == player || !IsClientConnected(player))
@ -195,12 +204,16 @@ public void OnClientPutInServer(int client)
char sPlayerSteamID[32]; char sPlayerSteamID[32];
GetClientAuthId(player, AuthId_Steam2, sPlayerSteamID, sizeof(sPlayerSteamID)); GetClientAuthId(player, AuthId_Steam2, sPlayerSteamID, sizeof(sPlayerSteamID));
if(MatchRegex(g_hReg_ValidateSteamID, sPlayerSteamID) <= 0)
continue;
if(StrEqual(sSteamID, sPlayerSteamID, false)) if(StrEqual(sSteamID, sPlayerSteamID, false))
{ {
if(!SteamClientAuthenticated(sSteamID)) if(!SteamClientAuthenticated(sSteamID))
{ {
LogMessage("%L was not authenticated with steam, steamid already connected. Kicking connector.", client); LogMessage("%L was not authenticated with steam, steamid already connected. Kicking connector.", client);
KickClient(client, "Please come back later."); KickClient(client, "Please come back later.");
return; return;
} }
@ -208,6 +221,7 @@ public void OnClientPutInServer(int client)
{ {
LogMessage("%L was not authenticated with steam, steamid already connected. Kicking connected.", player); LogMessage("%L was not authenticated with steam, steamid already connected. Kicking connected.", player);
KickClient(player, "Please come back later."); KickClient(player, "Please come back later.");
return; return;
} }