diff --git a/FakeClients/scripting/FakeClients.sp b/FakeClients/scripting/FakeClients.sp index 5cf4da5..1215408 100755 --- a/FakeClients/scripting/FakeClients.sp +++ b/FakeClients/scripting/FakeClients.sp @@ -11,7 +11,6 @@ ArrayList g_hNames; ArrayList g_hClanNames; -bool g_bFakePopulation[MAXPLAYERS + 1]; bool g_bMapEnded; int g_iBaseLatency[MAXPLAYERS + 1]; @@ -56,7 +55,7 @@ public void OnPluginStart() g_iPopulation = GetClientCount(false); for(int i = 1; i <= MaxClients; i++) { - if(IsClientConnected(i) && IsFakeClient(i)) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) g_iPopulation--; } g_bMapEnded = false; @@ -166,9 +165,8 @@ public void OnPluginEnd() { for(int i = 1; i <= MaxClients; i++) { - if(g_bFakePopulation[i]) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) { - g_bFakePopulation[i] = false; g_iLatency[i] = 0; KickClient(i, "Disconnect by user."); } @@ -241,7 +239,7 @@ public void OnMapEnd() g_iPopulation = GetClientCount(false); for(int i = 1; i <= MaxClients; i++) { - if(IsClientConnected(i) && IsFakeClient(i)) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) g_iPopulation--; } } @@ -264,7 +262,7 @@ public Action RandomizePing(Handle timer) { for(int i = 1; i <= MaxClients; i++) { - if(g_bFakePopulation[i]) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) g_iLatency[i] = g_iBaseLatency[i] + GetRandomInt(-3, 3); } return Plugin_Continue; @@ -284,7 +282,7 @@ public Action RandomizeNames(Handle timer) ArrayList hClanNames = g_hClanNames.Clone(); for(int i = 1; i <= MaxClients; i++) { - if(g_bFakePopulation[i]) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) { int iRand = GetRandomInt(0, hNames.Length - 1); char sName[MAX_NAME_LENGTH]; @@ -340,7 +338,7 @@ public Action UserMessage_SayText2(UserMsg msg_id, BfRead msg, const int[] playe return Plugin_Continue; } - if(g_bFakePopulation[client]) + if(IsClientConnected(client) && IsFakeClient(client) && !IsClientSourceTV(client)) return Plugin_Handled; return Plugin_Continue; @@ -357,14 +355,18 @@ public Action Command_DebugFakes(int client, int argc) for(int i = 1; i <= MaxClients; i++) { - if (g_bFakePopulation[i]) + if (!IsClientConnected(i)) + { + continue; + } + if (IsFakeClient(i) || IsClientSourceTV(i)) + { iFakes++; - - if (g_bFakePopulation[i] && GetClientTeam(i) > 0) + iPlayers--; + } + if (IsFakeClient(i) && GetClientTeam(i) > 0) iFakesInTeam++; - if(IsClientConnected(i) && IsFakeClient(i)) - iPlayers--; } ReplyToCommand(client, "[SM] There are currently %d Fake-Clients, from which %d are in Spectate.", iFakes, iFakes - iFakesInTeam); @@ -411,7 +413,7 @@ public Action Command_Fakes(int client, int args) { if(IsClientInGame(i)) { - if(g_bFakePopulation[i]) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) { GetClientName(i, aBuf2, sizeof(aBuf2)); StrCat(aBuf, sizeof(aBuf), aBuf2); @@ -436,7 +438,7 @@ public Action Command_Fakes(int client, int args) //---------------------------------------------------------------------------------------------------- public void OnClientConnected(int client) { - if (!g_bCheckRequested && !IsFakeClient(client)) + if (!g_bCheckRequested && !IsFakeClient(client) && !IsClientSourceTV(client)) { RequestFrame(CheckPopulation); g_bCheckRequested = true; @@ -450,13 +452,12 @@ public void OnClientDisconnect(int client) { if (client > 0) { - if(g_bFakePopulation[client]) + if(IsFakeClient(client) && !IsClientSourceTV(client)) { - g_bFakePopulation[client] = false; g_iLatency[client] = 0; } - if (!g_bCheckRequested && !IsFakeClient(client)) + if (!g_bCheckRequested && !IsFakeClient(client) && !IsClientSourceTV(client)) { RequestFrame(CheckPopulation); g_bCheckRequested = true; @@ -489,7 +490,7 @@ public void CheckPopulation() for(int i = 1; i <= MaxClients; i++) { - if(IsClientConnected(i) && IsClientInGame(i) && (IsFakeClient(i) || IsClientAutismBot(i) || IsClientSourceTV(i) || GetClientTeam(i) == CS_TEAM_SPECTATOR)) + if(IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i) && (IsFakeClient(i) || IsClientAutismBot(i) || IsClientSourceTV(i) || GetClientTeam(i) == CS_TEAM_SPECTATOR)) iPlayers--; } @@ -498,18 +499,24 @@ public void CheckPopulation() for(int i = 1; i <= MaxClients; i++) { - if (g_bFakePopulation[i]) + if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) iFakes++; } int iFakesInTeamNeeded = iPlayers; int iFakesNeeded = iPlayers; - if (GetClientCount(false) > 50) //counting all clients in total. + int full_client_count = GetClientCount(false); + + if (full_client_count > 50) //counting all clients in total. { iFakesInTeamNeeded = 0; iFakesNeeded = 0; } + else if (full_client_count >= 42) + { + return; + } else { iFakesInTeamNeeded = (iFakesNeeded / 5); @@ -529,7 +536,7 @@ public void CheckPopulation() char sName[MAX_NAME_LENGTH]; for(int i = 1; i <= MaxClients; i++) { - if(g_bFakePopulation[i]) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) { GetClientName(i, sName, sizeof(sName)); int iPos = hNames.FindString(sName); @@ -551,7 +558,6 @@ public void CheckPopulation() DispatchKeyValue(iIndex, "classname", "player"); DispatchSpawn(iIndex); - g_bFakePopulation[iIndex] = true; g_iBaseLatency[iIndex] = GetRandomInt(20, 110); g_iLatency[iIndex] = g_iBaseLatency[iIndex]; @@ -580,9 +586,8 @@ public void CheckPopulation() { for(int i = 1; i <= MaxClients; i++) { - if(g_bFakePopulation[i]) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) { - g_bFakePopulation[i] = false; g_iLatency[i] = 0; KickClient(i, "Disconnect by user."); iFakes--; @@ -594,7 +599,7 @@ public void CheckPopulation() for(int i = 1; i <= MaxClients; i++) { - if (g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T) + if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) >= CS_TEAM_T) iFakesInTeam++; } @@ -604,7 +609,7 @@ public void CheckPopulation() { for(int i = 1; i <= MaxClients; i++) { - if(g_bFakePopulation[i] && GetClientTeam(i) <= CS_TEAM_SPECTATOR) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) <= CS_TEAM_SPECTATOR) { ChangeClientTeam(i, CS_TEAM_CT); FakeClientCommandEx(i, "joinclass"); @@ -618,7 +623,7 @@ public void CheckPopulation() { for(int i = 1; i <= MaxClients; i++) { - if(g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) >= CS_TEAM_T) { ChangeClientTeam(i, CS_TEAM_SPECTATOR); iFakesInTeam--; @@ -636,7 +641,7 @@ public void OnGameFrame() { for(int i = 1; i <= MaxClients; i++) { - if(g_bFakePopulation[i]) + if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) { int iResEnt = GetPlayerResourceEntity(); @@ -651,7 +656,7 @@ public void OnGameFrame() /* public Action ZR_OnClientMotherZombieEligible(int client) { - if (g_bFakePopulation[client]) + if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i)) return Plugin_Handled; return Plugin_Continue;