Fix issues

This commit is contained in:
BotoX 2019-09-29 22:11:56 +02:00
parent 31a97d51d7
commit 19470d6924
2 changed files with 81 additions and 13 deletions

View File

@ -69,7 +69,7 @@ public void OnClientDisconnect(int client)
g_LastProcessed[client] = 0;
}
public void OnGameFrame()
public void OnRunThinkFunctions(bool simulating)
{
int minimum = GetGameTickCount() - 33;
for(int client = 1; client <= MaxClients; client++)

View File

@ -9,7 +9,10 @@
char g_cName[NUMBEROFNAMES][] = {"Dwelitram", "Gwyri", "Caredus", "Arerawia", "Vilali", "Astiwiel", "Vardonydd", "Ybaossa", "Umyk", "Nico50Pax", "Onand", "Thelian", "Nydaleth", "Chomarin", "Traedien", "Miev", "Kaaede", "Koamond", "TheRottenBenson", "BigLegend2017", "TRIGGEREDHarambexXx", "InPepe2016", "xXxMaster2012", "InBoixXx", "TheKopsing", "Cornelius", "Gustavo", "Bryant", "Winfred", "Nicolas", "Mitchel", "Dana", "Carrol", "Darell", "Ruben", "Jeromy", "Wade", "Scotty", "Salvatore", "Kory", "Don", "Morgan", "Kurtis", "Federico", "Darin", "css-ru", "aimbot", "lastkraftwagenfahrzeug", "edger", "clownface", "слово", "счастливый", "kara", "puta", "meow", "uncle sam", "FunBun", "Counter-Strike.Com.Ua", "For-css.Ru", "BOBO", "", "."};
bool g_bFakePopulation[MAXPLAYERS + 1];
bool g_bMapEnded;
int g_iLatency[MAXPLAYERS + 1];
int g_iAdminFakes;
bool g_bCheckRequested;
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -29,7 +32,12 @@ public Plugin myinfo =
public void OnPluginStart()
{
RegAdminCmd("sm_debugfakes", Command_DebugFakes, ADMFLAG_RCON, "");
CheckPopulation();
RegAdminCmd("sm_setfakes", Command_SetFakes, ADMFLAG_RCON, "");
g_iAdminFakes = -1;
g_bMapEnded = false;
RequestFrame(CheckPopulation);
}
//----------------------------------------------------------------------------------------------------
@ -48,6 +56,28 @@ public void OnPluginEnd()
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart()
{
g_bMapEnded = false;
//g_iAdminFakes = -1;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapEnd()
{
g_bMapEnded = true;
LogMessage("OnMapEnd");
//g_iAdminFakes = -1;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
@ -70,13 +100,42 @@ public Action Command_DebugFakes(int client, int argc)
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_SetFakes(int client, int argc)
{
if (argc < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_setfakes <amount of fakes>");
return Plugin_Handled;
}
char sArgs[16];
GetCmdArg(1, sArgs, sizeof(sArgs));
if (!StringToIntEx(sArgs, g_iAdminFakes))
{
ReplyToCommand(client, "[SM] Invalid value");
return Plugin_Handled;
}
ReplyToCommand(client, "[SM] You set the amount of Fake Players to %d.", g_iAdminFakes);
CheckPopulation();
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientConnected(int client)
{
if ((client > 0) && (!IsFakeClient(client)))
CheckPopulation();
if (!g_bCheckRequested && !IsFakeClient(client))
{
RequestFrame(CheckPopulation);
g_bCheckRequested = true;
}
}
//----------------------------------------------------------------------------------------------------
@ -92,8 +151,11 @@ public void OnClientDisconnect(int client)
g_iLatency[client] = 0;
}
if (!IsFakeClient(client))
CheckPopulation();
if (!g_bCheckRequested && !IsFakeClient(client))
{
RequestFrame(CheckPopulation);
g_bCheckRequested = true;
}
}
}
@ -102,6 +164,11 @@ public void OnClientDisconnect(int client)
//----------------------------------------------------------------------------------------------------
public void CheckPopulation()
{
g_bCheckRequested = false;
if(g_bMapEnded)
return;
int iPlayers = 0;
for(int i = 1; i <= MaxClients; i++)
{
@ -135,12 +202,7 @@ public void CheckPopulation()
}
else if(iPlayers > 55)
{
iFakesNeeded = 3;
iFakesInTeamNeeded = 2;
}
else if(iPlayers > 40)
{
iFakesInTeamNeeded = 3;
iFakesNeeded = 1;
}
else if (iPlayers > 20)
{
@ -162,12 +224,18 @@ public void CheckPopulation()
iFakesInTeamNeeded = 0;
}
if(g_iAdminFakes != -1)
iFakesNeeded = g_iAdminFakes;
if (iFakes != iFakesNeeded)
{
while (iFakes < iFakesNeeded)
{
int RandomName = GetRandomInt(0, NUMBEROFNAMES - 1);
int iIndex = CreateFakeClient(g_cName[RandomName]);
SetEntityFlags(iIndex, FL_CLIENT | FL_FAKECLIENT);
DispatchKeyValue(iIndex, "classname", "player");
DispatchSpawn(iIndex);
g_bFakePopulation[iIndex] = true;
g_iLatency[iIndex] = GetRandomInt(30, 120);
AdminId FakeAdmin = CreateAdmin();
@ -238,4 +306,4 @@ public void OnGameFrame()
SetEntProp(iResEnt, Prop_Send, "m_iPing", g_iLatency[i], _, i);
}
}
}
}