fixed the torchlight not being targeted i guess

This commit is contained in:
jenz 2025-12-14 12:35:52 +01:00
parent 4b27950b98
commit 126c976a65

View File

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