probably final redux of it
This commit is contained in:
parent
d396e006b9
commit
778fdd2f7a
@ -1,7 +1,6 @@
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include <zombiereloaded>
|
||||
#include <BotTargeting>
|
||||
#include <cstrike>
|
||||
|
||||
#pragma semicolon 1
|
||||
@ -45,7 +44,7 @@ public void OnPluginStart()
|
||||
g_hClanNames = CreateArray(arraySize);
|
||||
|
||||
g_iAdminFakes = -1;
|
||||
CreateTimer(20.0, RunPopulationCheck, _, TIMER_REPEAT);
|
||||
CreateTimer(2.0, RunPopulationCheck, _, TIMER_REPEAT);
|
||||
CreateTimer(3.0, RandomizePing, _, TIMER_REPEAT);
|
||||
CreateTimer(150.0, RandomizeNames, _, TIMER_REPEAT);
|
||||
|
||||
@ -189,7 +188,6 @@ public void OnMapEnd()
|
||||
{
|
||||
g_iAdminFakes = -1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -313,7 +311,7 @@ public Action Command_DebugFakes(int client, int argc)
|
||||
|
||||
}
|
||||
|
||||
ReplyToCommand(client, "[SM] There are currently %d Fake-Clients, from which %d are in Spectate.", iFakes, iFakes - iFakesInTeam);
|
||||
ReplyToCommand(client, "[SM] There are currently %d Fake-Clients, from which %d are in Spectate. Real Clients %d", iFakes, iFakes - iFakesInTeam, iPlayers);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
@ -392,87 +390,176 @@ public void OnClientDisconnect(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void CheckPopulation()
|
||||
{
|
||||
int iPlayers = 0;
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i) && !IsFakeClient(i) && !IsClientAutismBot(i) && !IsClientSourceTV(i) && GetClientTeam(i) > CS_TEAM_SPECTATOR)
|
||||
iPlayers++;
|
||||
}
|
||||
|
||||
int iPlayersSpectate = 0;
|
||||
int iPlayersInTeam = 0;
|
||||
int iFakesSpectate = 0;
|
||||
int iFakesInTeam = 0;
|
||||
|
||||
bool okay_to_change_count = true;
|
||||
if (iPlayers > 16)
|
||||
{
|
||||
iPlayers = 16;
|
||||
}
|
||||
int iFakesInTeamNeeded = RoundToFloor(iPlayers / 2.5);
|
||||
int iFakesNeeded = iPlayers;
|
||||
|
||||
iPlayers = 0;
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (IsClientConnected(i))
|
||||
iPlayers++;
|
||||
if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i))
|
||||
{
|
||||
if (!IsFakeClient(i) && !IsClientSourceTV(i))
|
||||
{
|
||||
if (GetClientTeam(i) > CS_TEAM_SPECTATOR)
|
||||
{
|
||||
iPlayersInTeam++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iPlayersSpectate++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetClientTeam(i) > CS_TEAM_SPECTATOR)
|
||||
{
|
||||
iFakesInTeam++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iFakesSpectate++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int iFakes = 0;
|
||||
int iPlayers = iPlayersInTeam + iPlayersSpectate + iFakesInTeam + iFakesSpectate;
|
||||
if (iPlayers >= 58)
|
||||
{
|
||||
if (iFakesInTeam > 0)
|
||||
{
|
||||
KickFakeFromTeam();
|
||||
}
|
||||
else if (iFakesSpectate > 1)
|
||||
{
|
||||
KickFakeFromSpec();
|
||||
}
|
||||
}
|
||||
else if (iPlayers >= 48 && iFakesInTeam + iFakesSpectate >= 10)
|
||||
{
|
||||
if (iFakesInTeam >= iFakesSpectate >= 0)
|
||||
{
|
||||
KickFakeFromTeam();
|
||||
}
|
||||
else if (iFakesSpectate >= iFakesInTeam >= 1)
|
||||
{
|
||||
KickFakeFromSpec();
|
||||
}
|
||||
}
|
||||
else if (iPlayers >= 43 && iFakesInTeam + iFakesSpectate >= 13)
|
||||
{
|
||||
if (iFakesInTeam >= iFakesSpectate >= 0)
|
||||
{
|
||||
KickFakeFromTeam();
|
||||
}
|
||||
else if (iFakesSpectate >= iFakesInTeam >= 1)
|
||||
{
|
||||
KickFakeFromSpec();
|
||||
}
|
||||
}
|
||||
else if (iPlayers >= 34 && iFakesInTeam + iFakesSpectate >= 16)
|
||||
{
|
||||
if (iFakesInTeam >= iFakesSpectate >= 0)
|
||||
{
|
||||
KickFakeFromTeam();
|
||||
}
|
||||
else if (iFakesSpectate >= iFakesInTeam >= 1)
|
||||
{
|
||||
KickFakeFromSpec();
|
||||
}
|
||||
}
|
||||
else if (iPlayers <= 32)
|
||||
{
|
||||
int some_number = 8;
|
||||
if (iPlayersSpectate + iPlayersInTeam < some_number * 2)
|
||||
{
|
||||
some_number = 4;
|
||||
}
|
||||
if (iFakesSpectate + iFakesInTeam < iPlayersSpectate + iPlayersInTeam + some_number)
|
||||
{
|
||||
CreateFake();
|
||||
some_number = 8;
|
||||
if (iPlayersSpectate + iFakesSpectate <= some_number * 2)
|
||||
{
|
||||
SetFakeToSpectate();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFakeToTeam();
|
||||
}
|
||||
}
|
||||
else if (iFakesSpectate + iFakesInTeam > iPlayersSpectate + iPlayersInTeam + some_number)
|
||||
{
|
||||
if (iPlayersSpectate + iFakesSpectate >= some_number * 2 && iFakesSpectate > 1)
|
||||
{
|
||||
KickFakeFromSpec();
|
||||
}
|
||||
else
|
||||
{
|
||||
KickFakeFromTeam();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFakeToSpectate()
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i))
|
||||
iFakes++;
|
||||
if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) >= CS_TEAM_T)
|
||||
{
|
||||
ChangeClientTeam(i, CS_TEAM_SPECTATOR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iPlayers > 53)
|
||||
public void SetFakeToTeam()
|
||||
{
|
||||
iFakesInTeamNeeded = 0;
|
||||
iFakesNeeded = 0;
|
||||
}
|
||||
else if (iPlayers > 48 && iFakes > 10)
|
||||
{
|
||||
iFakesInTeamNeeded = 3;
|
||||
iFakesNeeded = 10;
|
||||
}
|
||||
else if (iPlayers >= 42)
|
||||
{
|
||||
okay_to_change_count = false;
|
||||
}
|
||||
|
||||
int specs = 0;
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) <= CS_TEAM_SPECTATOR)
|
||||
if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) <= CS_TEAM_SPECTATOR)
|
||||
{
|
||||
specs++;
|
||||
ChangeClientTeam(i, CS_TEAM_CT);
|
||||
FakeClientCommandEx(i, "joinclass");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//LogMessage("specs: %i", specs);
|
||||
if (specs >= 14 && iFakesNeeded > 0)
|
||||
public void KickFakeFromTeam()
|
||||
{
|
||||
iFakesInTeamNeeded = iFakes;
|
||||
if (iFakes >= 5)
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
iFakesNeeded = iFakesInTeamNeeded = 5;
|
||||
if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) > CS_TEAM_SPECTATOR)
|
||||
{
|
||||
g_iLatency[i] = 0;
|
||||
KickClient(i, "Disconnect by user.");
|
||||
break;
|
||||
}
|
||||
okay_to_change_count = true;
|
||||
//LogMessage("iFakesInTeamNeeded: %i", iFakesInTeamNeeded);
|
||||
}
|
||||
else if (specs <= 9)
|
||||
{
|
||||
iFakesInTeamNeeded = (iFakesNeeded / 5);
|
||||
}
|
||||
|
||||
if (iFakesInTeamNeeded < 0)
|
||||
public void KickFakeFromSpec()
|
||||
{
|
||||
iFakesInTeamNeeded = 0;
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) <= CS_TEAM_SPECTATOR)
|
||||
{
|
||||
g_iLatency[i] = 0;
|
||||
KickClient(i, "Disconnect by user.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (iFakes != iFakesNeeded && okay_to_change_count)
|
||||
public void CreateFake()
|
||||
{
|
||||
if (iFakes < iFakesNeeded)
|
||||
if (g_hNames.Length == 0 || g_hClanNames.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ArrayList hNames = g_hNames.Clone();
|
||||
char sName[MAX_NAME_LENGTH];
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
@ -517,60 +604,6 @@ public void CheckPopulation()
|
||||
else
|
||||
{
|
||||
CS_SetClientClanTag(iIndex, "");
|
||||
}
|
||||
iFakes++;
|
||||
}
|
||||
|
||||
if (iFakes > iFakesNeeded)
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i))
|
||||
{
|
||||
g_iLatency[i] = 0;
|
||||
KickClient(i, "Disconnect by user.");
|
||||
iFakes--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) >= CS_TEAM_T)
|
||||
iFakesInTeam++;
|
||||
}
|
||||
|
||||
//LogMessage("iFakesInTeam: %i. iFakesInTeamNeeded: %i", iFakesInTeam, iFakesInTeamNeeded);
|
||||
if (iFakesInTeam != iFakesInTeamNeeded && g_iAdminFakes == -1)
|
||||
{
|
||||
if (iFakesInTeam < iFakesInTeamNeeded)
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) <= CS_TEAM_SPECTATOR)
|
||||
{
|
||||
ChangeClientTeam(i, CS_TEAM_CT);
|
||||
FakeClientCommandEx(i, "joinclass");
|
||||
iFakesInTeam++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iFakesInTeam > iFakesInTeamNeeded)
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) >= CS_TEAM_T)
|
||||
{
|
||||
ChangeClientTeam(i, CS_TEAM_SPECTATOR);
|
||||
iFakesInTeam--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,13 +625,3 @@ public void OnGameFrame()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public Action ZR_OnClientMotherZombieEligible(int client)
|
||||
{
|
||||
if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i))
|
||||
return Plugin_Handled;
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user