From c8bcee4377a10d6f0f9b2c0400881caa9fd3af15 Mon Sep 17 00:00:00 2001 From: jenz Date: Mon, 13 Mar 2023 20:00:35 +0100 Subject: [PATCH] removed fakeclients, sourcetv, not yet connected clients, autismbots and nosteamers from counting towards player requirement for maps --- .../scripting/mapchooser_extended.sp | 55 ++++++++++++++++--- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/mapchooser_extended/scripting/mapchooser_extended.sp b/mapchooser_extended/scripting/mapchooser_extended.sp index c5876edd..3aa4973b 100755 --- a/mapchooser_extended/scripting/mapchooser_extended.sp +++ b/mapchooser_extended/scripting/mapchooser_extended.sp @@ -49,6 +49,7 @@ #include #include #include +#include #pragma semicolon 1 #pragma newdecls required @@ -140,6 +141,9 @@ int g_NominateCount = 0; int g_NominateReservedCount = 0; MapChange g_ChangeTime; +//check if autismbot +bool is_bot_player[MAXPLAYERS + 1]; + Handle g_NominationsResetForward = INVALID_HANDLE; Handle g_MapVoteStartedForward = INVALID_HANDLE; @@ -605,6 +609,7 @@ public void OnClientDisconnect_Post(int client) public void OnClientDisconnect(int client) { + is_bot_player[client] = false; int index = FindValueInArray(g_NominateOwners, client); if(index == -1) @@ -2765,22 +2770,56 @@ stock int InternalGetMapTimeRestriction(const char[] map) return 0; } +public void OnClientPostAdminCheck(int client) +{ + is_bot_player[client] = false; + char auth[50]; + GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); + if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false)) + { + is_bot_player[client] = true; + } + if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false)) + { + is_bot_player[client] = true; + } + if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false)) + { + is_bot_player[client] = true; + } + if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false)) + { + is_bot_player[client] = true; + } +} + // <0 = Less than MinPlayers // 0 = Okay // >0 = More than MaxPlayers stock int InternalGetMapPlayerRestriction(const char[] map) { - int NumPlayers = GetClientCount(false); - int MinPlayers = InternalGetMapMinPlayers(map); - int MaxPlayers = InternalGetMapMaxPlayers(map); + //int NumPlayers = GetClientCount(false); + int NumPlayers = 0; + //excluding non connected players, fakeclients, sourceTV, autism bots and nosteamers from player count restriction + for (int client = 1; client <= MaxClients; client++) + { + if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client) && !IsClientSourceTV(client) && !is_bot_player[client] + && PM_IsPlayerSteam(client)) + { + NumPlayers++; + } + } - if(MinPlayers && NumPlayers < MinPlayers) - return NumPlayers - MinPlayers; + int MinPlayers = InternalGetMapMinPlayers(map); + int MaxPlayers = InternalGetMapMaxPlayers(map); - if(MaxPlayers && NumPlayers > MaxPlayers) - return NumPlayers - MaxPlayers; + if(MinPlayers && NumPlayers < MinPlayers) + return NumPlayers - MinPlayers; - return 0; + if(MaxPlayers && NumPlayers > MaxPlayers) + return NumPlayers - MaxPlayers; + + return 0; } stock bool InternalAreRestrictionsActive()