[FakeClients] Remove bot motherzm exclusion & fix indents.

This commit is contained in:
zaCade 2024-06-22 10:59:06 +02:00
parent ac7de82c6c
commit 87bb74837f

View File

@ -12,9 +12,6 @@ ArrayList g_hNames;
bool g_bFakePopulation[MAXPLAYERS + 1]; bool g_bFakePopulation[MAXPLAYERS + 1];
bool g_bMapEnded; bool g_bMapEnded;
//check if autismbot
bool is_bot_player[MAXPLAYERS + 1];
int g_iBaseLatency[MAXPLAYERS + 1]; int g_iBaseLatency[MAXPLAYERS + 1];
int g_iLatency[MAXPLAYERS + 1]; int g_iLatency[MAXPLAYERS + 1];
@ -315,21 +312,20 @@ public void OnClientConnected(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
if (client > 0) if (client > 0)
{ {
if(g_bFakePopulation[client]) if(g_bFakePopulation[client])
{ {
g_bFakePopulation[client] = false; g_bFakePopulation[client] = false;
g_iLatency[client] = 0; g_iLatency[client] = 0;
} }
if (!g_bCheckRequested && !IsFakeClient(client)) if (!g_bCheckRequested && !IsFakeClient(client))
{ {
RequestFrame(CheckPopulation); RequestFrame(CheckPopulation);
g_bCheckRequested = true; g_bCheckRequested = true;
} }
is_bot_player[client] = false; }
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -337,140 +333,140 @@ public void OnClientDisconnect(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void CheckPopulation() public void CheckPopulation()
{ {
g_bCheckRequested = false; g_bCheckRequested = false;
if(g_bMapEnded) if(g_bMapEnded)
return; return;
int iPlayers = GetClientCount(false); int iPlayers = GetClientCount(false);
for(int i = 1; i <= MaxClients; i++) for(int i = 1; i <= MaxClients; i++)
{ {
if(IsClientConnected(i) && IsFakeClient(i)) if(IsClientConnected(i) && IsFakeClient(i))
iPlayers--; iPlayers--;
} }
int iFakes = 0; int iFakes = 0;
int iFakesInTeam = 0; int iFakesInTeam = 0;
for(int i = 1; i <= MaxClients; i++) for(int i = 1; i <= MaxClients; i++)
{ {
if (g_bFakePopulation[i]) if (g_bFakePopulation[i])
iFakes++; iFakes++;
} }
int iFakesNeeded = 0; int iFakesNeeded = 0;
int iFakesInTeamNeeded = 0; int iFakesInTeamNeeded = 0;
//24 to account for 4 autismbots.
iFakesNeeded = 24 - RoundToFloor(iPlayers / 1.5);
if (iFakesNeeded < 0)
{
iFakesNeeded = 0;
iFakesInTeamNeeded = 0;
}
else
{
iFakesInTeamNeeded = iFakesNeeded / 3;
}
if(g_iAdminFakes != -1) //24 to account for 4 autismbots.
iFakesNeeded = g_iAdminFakes; iFakesNeeded = 24 - RoundToFloor(iPlayers / 1.5);
if (iFakesNeeded < 0)
{
iFakesNeeded = 0;
iFakesInTeamNeeded = 0;
}
else
{
iFakesInTeamNeeded = iFakesNeeded / 3;
}
if (iFakes != iFakesNeeded) if(g_iAdminFakes != -1)
{ iFakesNeeded = g_iAdminFakes;
while (iFakes < iFakesNeeded && !g_bBlockInstantFakeConnects)
{
ArrayList hNames = g_hNames.Clone();
char sName[MAX_NAME_LENGTH];
for(int i = 1; i <= MaxClients; i++)
{
if(g_bFakePopulation[i])
{
GetClientName(i, sName, sizeof(sName));
int iPos = hNames.FindString(sName);
if (iPos > -1)
hNames.Erase(iPos);
}
}
int iRand = GetRandomInt(0, hNames.Length - 1); if (iFakes != iFakesNeeded)
hNames.GetString(iRand, sName, sizeof(sName)); {
delete hNames; while (iFakes < iFakesNeeded && !g_bBlockInstantFakeConnects)
{
ArrayList hNames = g_hNames.Clone();
char sName[MAX_NAME_LENGTH];
for(int i = 1; i <= MaxClients; i++)
{
if(g_bFakePopulation[i])
{
GetClientName(i, sName, sizeof(sName));
int iPos = hNames.FindString(sName);
if (iPos > -1)
hNames.Erase(iPos);
}
}
int iIndex = CreateFakeClient(sName); int iRand = GetRandomInt(0, hNames.Length - 1);
hNames.GetString(iRand, sName, sizeof(sName));
delete hNames;
if(iIndex < 1 || iIndex > MaxClients) int iIndex = CreateFakeClient(sName);
return;
SetEntityFlags(iIndex, FL_CLIENT); if(iIndex < 1 || iIndex > MaxClients)
DispatchKeyValue(iIndex, "classname", "player"); return;
DispatchSpawn(iIndex);
g_bFakePopulation[iIndex] = true; SetEntityFlags(iIndex, FL_CLIENT);
g_iBaseLatency[iIndex] = GetRandomInt(20, 110); DispatchKeyValue(iIndex, "classname", "player");
g_iLatency[iIndex] = g_iBaseLatency[iIndex]; DispatchSpawn(iIndex);
AdminId FakeAdmin = CreateAdmin(); g_bFakePopulation[iIndex] = true;
SetAdminFlag(FakeAdmin, Admin_Custom6, true); g_iBaseLatency[iIndex] = GetRandomInt(20, 110);
SetUserAdmin(iIndex, FakeAdmin, true); g_iLatency[iIndex] = g_iBaseLatency[iIndex];
//CS_SetClientClanTag(iIndex, "UNLOZE");
iFakes++;
g_bBlockInstantFakeConnects = true; AdminId FakeAdmin = CreateAdmin();
} SetAdminFlag(FakeAdmin, Admin_Custom6, true);
SetUserAdmin(iIndex, FakeAdmin, true);
//CS_SetClientClanTag(iIndex, "UNLOZE");
iFakes++;
while (iFakes > iFakesNeeded) g_bBlockInstantFakeConnects = true;
{ }
for(int i = 1; i <= MaxClients; i++)
{
if(g_bFakePopulation[i])
{
g_bFakePopulation[i] = false;
g_iLatency[i] = 0;
KickClient(i, "Disconnect by user.");
iFakes--;
break;
}
}
}
}
for(int i = 1; i <= MaxClients; i++) while (iFakes > iFakesNeeded)
{ {
if (g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T) for(int i = 1; i <= MaxClients; i++)
iFakesInTeam++; {
} if(g_bFakePopulation[i])
{
g_bFakePopulation[i] = false;
g_iLatency[i] = 0;
KickClient(i, "Disconnect by user.");
iFakes--;
break;
}
}
}
}
if (iFakes == iFakesNeeded && iFakesInTeam != iFakesInTeamNeeded && g_iAdminFakes == -1) for(int i = 1; i <= MaxClients; i++)
{ {
while (iFakesInTeam < iFakesInTeamNeeded) if (g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T)
{ iFakesInTeam++;
for(int i = 1; i <= MaxClients; i++) }
{
if(g_bFakePopulation[i] && GetClientTeam(i) <= CS_TEAM_SPECTATOR)
{
ChangeClientTeam(i, CS_TEAM_CT);
FakeClientCommandEx(i, "joinclass");
iFakesInTeam++;
break;
}
}
}
while (iFakesInTeam > iFakesInTeamNeeded) if (iFakes == iFakesNeeded && iFakesInTeam != iFakesInTeamNeeded && g_iAdminFakes == -1)
{ {
for(int i = 1; i <= MaxClients; i++) while (iFakesInTeam < iFakesInTeamNeeded)
{ {
if(g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T) for(int i = 1; i <= MaxClients; i++)
{ {
ChangeClientTeam(i, CS_TEAM_SPECTATOR); if(g_bFakePopulation[i] && GetClientTeam(i) <= CS_TEAM_SPECTATOR)
iFakesInTeam--; {
break; ChangeClientTeam(i, CS_TEAM_CT);
} FakeClientCommandEx(i, "joinclass");
} iFakesInTeam++;
} break;
} }
}
}
while (iFakesInTeam > iFakesInTeamNeeded)
{
for(int i = 1; i <= MaxClients; i++)
{
if(g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T)
{
ChangeClientTeam(i, CS_TEAM_SPECTATOR);
iFakesInTeam--;
break;
}
}
}
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -494,31 +490,8 @@ public void OnGameFrame()
public Action ZR_OnClientMotherZombieEligible(int client) public Action ZR_OnClientMotherZombieEligible(int client)
{ {
if (g_bFakePopulation[client] || is_bot_player[client]) if (g_bFakePopulation[client])
return Plugin_Handled; return Plugin_Handled;
return Plugin_Continue; return Plugin_Continue;
}
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;
}
} }