diff --git a/AntiNoob/scripting/knockback_low_pop_modifier.sp b/AntiNoob/scripting/knockback_low_pop_modifier.sp index 0a08a76..e8eba54 100644 --- a/AntiNoob/scripting/knockback_low_pop_modifier.sp +++ b/AntiNoob/scripting/knockback_low_pop_modifier.sp @@ -3,6 +3,7 @@ #include int g_iDoingMapTouristMode; +int g_iActivePlayerCount; public Plugin myinfo = { @@ -16,13 +17,34 @@ public Plugin myinfo = public void OnPluginStart() { HookEvent("round_start", OnRoundStart); + CreateTimer(120.0, CheckPopulation, _, TIMER_REPEAT); g_iDoingMapTouristMode = 0; + g_iActivePlayerCount = 0; +} + +public Action CheckPopulation(Handle timer) +{ + int TimeLeft; + if (GetMapTimeLeft(TimeLeft) && TimeLeft < 0) + { + return Plugin_Continue; + } + g_iActivePlayerCount = 0; + for (int i = 1; i <= MaxClients; i++) + { + if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i)) + { + g_iActivePlayerCount++; + } + } + return Plugin_Continue; } public void OnPluginEnd() { ServerCommand("zr_class_set_multiplier zombies knockback 1.0"); g_iDoingMapTouristMode = 0; + g_iActivePlayerCount = 0; } public void OnMapEnd() @@ -49,27 +71,12 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) ServerCommand("zr_class_set_multiplier zombies knockback 1.0"); ServerCommand("sm_iammo @all 0"); - int TimeLeft; - if (GetMapTimeLeft(TimeLeft) && TimeLeft < 0) - { - return; - } - - int active_player_count = 0; - for (int i = 1; i <= MaxClients; i++) - { - if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i)) - { - active_player_count++; - } - } - int choosen_number = 28; - if (g_iDoingMapTouristMode > active_player_count > 0) + if (g_iDoingMapTouristMode > g_iActivePlayerCount > 0) { CreateTimer(3.0, SetHealthOnCT); } - else if (active_player_count < choosen_number) + else if (g_iActivePlayerCount < choosen_number) { int zombie_ratio = GetConVarInt(FindConVar("zr_infect_mzombie_ratio")); int infectectable_players = 0;