diff --git a/VPN-Check/scripting/VPN-Check.sp b/VPN-Check/scripting/VPN-Check.sp index 60933e32..db93fb85 100644 --- a/VPN-Check/scripting/VPN-Check.sp +++ b/VPN-Check/scripting/VPN-Check.sp @@ -1,14 +1,21 @@ #include #include #include + +#undef REQUIRE_PLUGIN #include +#define REQUIRE_PLUGIN + #pragma newdecls required #pragma semicolon 1 -/* INTEGERS */ +ConVar g_cvBlockNoSteamVPN; + int g_bStatus[MAXPLAYERS+1] = {0,...}; +bool g_bNSMLoaded; + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -25,7 +32,8 @@ public Plugin myinfo = //---------------------------------------------------------------------------------------------------- public void OnPluginStart() { - RegAdminCmd("sm_vpn", Command_CheckVPN, ADMFLAG_RCON); + g_cvBlockNoSteamVPN = CreateConVar("sm_nosteam_block_vpn", "1", "Kick nosteamers that use VPN.", FCVAR_NONE, true, 0.0, true, 1.0); + for (int client = 1; client <= MaxClients; client++) { if (!IsValidClient(client) || IsClientSourceTV(client)) @@ -48,6 +56,36 @@ public void OnPluginStart() delete hRequest; } } + + RegAdminCmd("sm_vpn", Command_CheckVPN, ADMFLAG_RCON); + + AutoExecConfig(); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnAllPluginsLoaded() +{ + g_bNSMLoaded = LibraryExists("NoSteamManager"); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnLibraryAdded(const char[] sName) +{ + if (strcmp(sName, "NoSteamManager", false) == 0) + g_bNSMLoaded = true; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnLibraryRemoved(const char[] sName) +{ + if (strcmp(sName, "NoSteamManager", false) == 0) + g_bNSMLoaded = false; } //---------------------------------------------------------------------------------------------------- @@ -75,10 +113,15 @@ public Action Command_CheckVPN(int client, int args) GetClientAuthId(i, AuthId_Steam2, sSteamID, sizeof(sSteamID)); GetClientIP(i, sIP, sizeof(sIP)); - if(!NSM_IsPlayerSteam(i)) - Format(sBuffer, sizeof(sBuffer), "%s\"%L\"[NOSTEAM] is possibly using a VPN (%s).\n", sBuffer, i, sIP); + if (g_bNSMLoaded) + { + if (!NSM_IsPlayerSteam(i)) + Format(sBuffer, sizeof(sBuffer), "%s\"%L\"[NOSTEAM] is possibly using a VPN (%s).\n", sBuffer, i, sIP); + else + Format(sBuffer, sizeof(sBuffer), "%s\"%L\"[STEAM] is possibly using a VPN (%s).\n", sBuffer, i, sIP); + } else - Format(sBuffer, sizeof(sBuffer), "%s\"%L\"[STEAM] is possibly using a VPN (%s).\n", sBuffer, i, sIP); + Format(sBuffer, sizeof(sBuffer), "%s\"%L\" is possibly using a VPN (%s).\n", sBuffer, i, sIP); bFound = true; } @@ -193,25 +236,31 @@ public int OnClientPostAdminCheck_OnTransferResponse(char[] sData, int iSerial) { if(IsValidClient(i) && CheckCommandAccess(i, "sm_vpn", ADMFLAG_RCON)) { - if(!NSM_IsPlayerSteam(client)) + if (g_bNSMLoaded) { - CPrintToChat(i, "{green}[SM]{default} %L[NOSTEAM] is possibly using a {red}VPN {default}(IP: %s). Client will be kicked.", client, sIP); - KickClient(client, "VPN not allowed"); - LogAction(client, -1, "\"%L\"[NOSTEAM] is possibly using a VPN (IP: %s). Client got kicked.", client, sIP); + if(!NSM_IsPlayerSteam(client)) + { + if (g_cvBlockNoSteamVPN.BoolValue) + { + CPrintToChat(i, "{green}[SM]{default} %L[NOSTEAM] is possibly using a {red}VPN {default}(IP: %s). Client will be kicked.", client, sIP); + KickClient(client, "VPN not allowed"); + LogAction(client, -1, "\"%L\"[NOSTEAM] is possibly using a VPN (IP: %s). Client got kicked.", client, sIP); + } + else + CPrintToChat(i, "{green}[SM]{default} %L[NOSTEAM] is possibly using a {red}VPN {default}(IP: %s).", client, sIP); + } + else + CPrintToChat(i, "{green}[SM]{default} %L[STEAM] is possibly using a {red}VPN {default}(IP: %s).", client, sIP); } else - CPrintToChat(i, "{green}[SM]{default} %L[STEAM] is possibly using a {red}VPN {default}(IP: %s).", client, sIP); + CPrintToChat(i, "{green}[SM]{default} %L is possibly using a {red}VPN {default}(IP: %s).", client, sIP); } } } else if (strcmp(sData, "N", false) == 0) - { g_bStatus[client] = 0; - } else if (strcmp(sData, "X", false) == 0) - { g_bStatus[client] = 2; - } } //----------------------------------------------------------------------------------------------------