adding clantags from hlstats, names from the racetimer and just generally changed fakeclients amount. fakeclients amount is a dumb thing to change tbh

This commit is contained in:
jenz 2024-06-26 16:59:26 +02:00
parent 72ff8eb0ab
commit 7753c52b68

View File

@ -8,6 +8,7 @@
#define MAXNAMES 500 #define MAXNAMES 500
ArrayList g_hNames; ArrayList g_hNames;
ArrayList g_hClanNames;
bool g_bFakePopulation[MAXPLAYERS + 1]; bool g_bFakePopulation[MAXPLAYERS + 1];
bool g_bMapEnded; bool g_bMapEnded;
@ -22,6 +23,9 @@ bool g_bCheckRequested;
bool g_bBlockInstantFakeConnects; bool g_bBlockInstantFakeConnects;
Database g_hDatabase;
Database g_hDatabase_hlstats;
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -30,7 +34,7 @@ public Plugin myinfo =
name = "ImprovedHitboxes", //camouflage name = "ImprovedHitboxes", //camouflage
author = "Neon + Dogan + Botox", author = "Neon + Dogan + Botox",
description = "Handle Hitboxes via Plugin", description = "Handle Hitboxes via Plugin",
version = "5.3.0", version = "5.3.1",
url = "https://steamcommunity.com/id/n3ontm" url = "https://steamcommunity.com/id/n3ontm"
}; };
@ -45,6 +49,7 @@ public void OnPluginStart()
int arraySize = ByteCountToCells(MAX_NAME_LENGTH); int arraySize = ByteCountToCells(MAX_NAME_LENGTH);
g_hNames = CreateArray(arraySize); g_hNames = CreateArray(arraySize);
g_hClanNames = CreateArray(arraySize);
g_iAdminFakes = -1; g_iAdminFakes = -1;
g_iPopulation = GetClientCount(false); g_iPopulation = GetClientCount(false);
@ -55,13 +60,94 @@ public void OnPluginStart()
} }
g_bMapEnded = false; g_bMapEnded = false;
g_bBlockInstantFakeConnects = false; g_bBlockInstantFakeConnects = false;
CreateTimer(5.0, BlockInstantFakeConnects, _, TIMER_REPEAT); CreateTimer(40.0, BlockInstantFakeConnects, _, TIMER_REPEAT);
CreateTimer(3.0, RandomizePing, _, TIMER_REPEAT); CreateTimer(3.0, RandomizePing, _, TIMER_REPEAT);
CreateTimer(150.0, RandomizeNames, _, TIMER_REPEAT); CreateTimer(150.0, RandomizeNames, _, TIMER_REPEAT);
HookUserMessage(GetUserMessageId("SayText2"), UserMessage_SayText2, true); HookUserMessage(GetUserMessageId("SayText2"), UserMessage_SayText2, true);
RequestFrame(CheckPopulation); RequestFrame(CheckPopulation);
if (!g_hDatabase)
{
Database.Connect(SQL_OnDatabaseConnect, "racetimercss");
}
if (!g_hDatabase_hlstats)
{
Database.Connect(SQL_OnDatabaseConnect_hlstats, "hlstatsx");
}
}
public void SQL_OnDatabaseConnect_hlstats(Database db, const char[] error, any data)
{
if(!db || strlen(error))
{
LogError("Database error: %s", error);
return;
}
g_hDatabase_hlstats = db;
randomize_clantags();
}
public void randomize_clantags()
{
char sQuery[512];
Format(sQuery, sizeof(sQuery), "select DISTINCT tag from unloze_stats.hlstats_Clans ORDER BY RAND() limit 500");
g_hDatabase_hlstats.Query(SQL_OnQueryCompleted_hlstats, sQuery, DBPrio_Low);
}
public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
{
if(!db || strlen(error))
{
LogError("Database error: %s", error);
return;
}
g_hDatabase = db;
randomize_names();
}
public void randomize_names()
{
char sQuery[512];
Format(sQuery, sizeof(sQuery), "select name from unloze_racetimer_css.zetimer_table_new ORDER BY RAND() limit 500");
g_hDatabase.Query(SQL_OnQueryCompleted, sQuery, DBPrio_Low);
}
public void SQL_OnQueryCompleted_hlstats(Database db, DBResultSet results, const char[] error, int iSerial)
{
if (!db || strlen(error))
{
delete results;
LogError("Query error 3: %s", error);
return;
}
while (results.RowCount && results.FetchRow())
{
char sName[MAX_NAME_LENGTH];
results.FetchString(0, sName, sizeof(sName));
g_hClanNames.PushString(sName);
}
delete results;
}
public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] error, int iSerial)
{
if (!db || strlen(error))
{
delete results;
LogError("Query error 3: %s", error);
return;
}
while (results.RowCount && results.FetchRow())
{
char sName[MAX_NAME_LENGTH];
results.FetchString(0, sName, sizeof(sName));
g_hNames.PushString(sName);
}
delete results;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -85,6 +171,28 @@ public void OnPluginEnd()
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnMapStart() public void OnMapStart()
{ {
g_hNames.Clear();
g_hClanNames.Clear();
if (!g_hDatabase)
{
Database.Connect(SQL_OnDatabaseConnect, "racetimercss");
}
else
{
randomize_names();
}
if (!g_hDatabase_hlstats)
{
Database.Connect(SQL_OnDatabaseConnect_hlstats, "hlstatsx");
}
else
{
randomize_clantags();
}
/*
char sFile[PLATFORM_MAX_PATH]; char sFile[PLATFORM_MAX_PATH];
char sLine[MAX_NAME_LENGTH]; char sLine[MAX_NAME_LENGTH];
BuildPath(Path_SM, sFile, sizeof(sFile), "configs/fakeclients_names.txt"); BuildPath(Path_SM, sFile, sizeof(sFile), "configs/fakeclients_names.txt");
@ -107,7 +215,7 @@ public void OnMapStart()
} }
else else
SetFailState("Could not open file: configs/fakeclients_names.txt"); SetFailState("Could not open file: configs/fakeclients_names.txt");
*/
g_bMapEnded = false; g_bMapEnded = false;
@ -159,6 +267,7 @@ public Action RandomizePing(Handle timer)
public Action RandomizeNames(Handle timer) public Action RandomizeNames(Handle timer)
{ {
ArrayList hNames = g_hNames.Clone(); ArrayList hNames = g_hNames.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(g_bFakePopulation[i])
@ -168,9 +277,23 @@ public Action RandomizeNames(Handle timer)
hNames.GetString(iRand, sName, sizeof(sName)); hNames.GetString(iRand, sName, sizeof(sName));
hNames.Erase(iRand); hNames.Erase(iRand);
SetClientName(i, sName); SetClientName(i, sName);
if (GetRandomInt(0, 5) >= 3)
{
int iRandClans = GetRandomInt(0, hClanNames.Length - 1);
hClanNames.GetString(iRandClans, sName, sizeof(sName));
hClanNames.Erase(iRandClans);
CS_SetClientClanTag(i, sName);
}
else
{
CS_SetClientClanTag(i, "");
}
} }
} }
delete hNames; delete hNames;
delete hClanNames;
return Plugin_Continue; return Plugin_Continue;
} }
@ -328,11 +451,22 @@ public void OnClientDisconnect(int client)
} }
} }
public Action repeatCheckPopulation(Handle timer)
{
CheckPopulation();
return Plugin_Continue;
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void CheckPopulation() public void CheckPopulation()
{ {
if (g_hNames.Length == 0 || g_hClanNames.Length == 0)
{
CreateTimer(5.0, repeatCheckPopulation);
return;
}
g_bCheckRequested = false; g_bCheckRequested = false;
if(g_bMapEnded) if(g_bMapEnded)
@ -358,17 +492,50 @@ public void CheckPopulation()
int iFakesNeeded = 0; int iFakesNeeded = 0;
int iFakesInTeamNeeded = 0; int iFakesInTeamNeeded = 0;
//24 to account for 4 autismbots. int max = 2;
iFakesNeeded = 24 - RoundToFloor(iPlayers / 1.5); int min = 1;
if (iFakesNeeded < 0)
if (iPlayers == 1)
{
max = iPlayers * 5;
min = 3;
}
else if (iPlayers < 6)
{
max = iPlayers * 5;
min = iPlayers * 2;
}
else if (iPlayers < 11)
{
max = iPlayers * 2;
min = iPlayers * 1;
}
else if (iPlayers < 20)
{
max = iPlayers * 1;
min = RoundToFloor(iPlayers * 0.5);
}
else
{
max = RoundToFloor(iPlayers * 0.5);
min = RoundToFloor(iPlayers * 0.1);
}
int randomAmount = GetRandomInt(min, max);
iFakesNeeded = randomAmount - iPlayers;
if (iFakesNeeded < 0 || iPlayers > 25)
{ {
iFakesNeeded = 0; iFakesNeeded = 0;
iFakesInTeamNeeded = 0; iFakesInTeamNeeded = 0;
} }
else else
{ {
iFakesInTeamNeeded = iFakesNeeded / 3; iFakesInTeamNeeded = iFakesNeeded / 2;
} }
if (iFakesInTeamNeeded < 0)
{
iFakesInTeamNeeded = 0;
}
if(g_iAdminFakes != -1) if(g_iAdminFakes != -1)
iFakesNeeded = g_iAdminFakes; iFakesNeeded = g_iAdminFakes;
@ -410,7 +577,19 @@ public void CheckPopulation()
AdminId FakeAdmin = CreateAdmin(); AdminId FakeAdmin = CreateAdmin();
SetAdminFlag(FakeAdmin, Admin_Custom6, true); SetAdminFlag(FakeAdmin, Admin_Custom6, true);
SetUserAdmin(iIndex, FakeAdmin, true); SetUserAdmin(iIndex, FakeAdmin, true);
//CS_SetClientClanTag(iIndex, "UNLOZE");
if (GetRandomInt(0, 5) >= 3)
{
ArrayList hClanNames = g_hClanNames.Clone();
iRand = GetRandomInt(0, hClanNames.Length - 1);
hClanNames.GetString(iRand, sName, sizeof(sName));
delete hClanNames;
CS_SetClientClanTag(iIndex, sName);
}
else
{
CS_SetClientClanTag(iIndex, "");
}
iFakes++; iFakes++;
g_bBlockInstantFakeConnects = true; g_bBlockInstantFakeConnects = true;