From 19470d692418740352e3c1025e2bab362644fa02 Mon Sep 17 00:00:00 2001 From: BotoX Date: Sun, 29 Sep 2019 22:11:56 +0200 Subject: [PATCH] Fix issues --- AntiLagSwitch/scripting/AntiLagSwitch.sp | 2 +- FakePopulation/scripting/FakePopulation.sp | 92 +++++++++++++++++++--- 2 files changed, 81 insertions(+), 13 deletions(-) diff --git a/AntiLagSwitch/scripting/AntiLagSwitch.sp b/AntiLagSwitch/scripting/AntiLagSwitch.sp index 719545a2..361c14fe 100644 --- a/AntiLagSwitch/scripting/AntiLagSwitch.sp +++ b/AntiLagSwitch/scripting/AntiLagSwitch.sp @@ -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++) diff --git a/FakePopulation/scripting/FakePopulation.sp b/FakePopulation/scripting/FakePopulation.sp index e4220ac2..449cb34b 100644 --- a/FakePopulation/scripting/FakePopulation.sp +++ b/FakePopulation/scripting/FakePopulation.sp @@ -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 "); + 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); } } -} \ No newline at end of file +}