instead of checking player count on each round start its checked globally every 2 minutes so that the first round on new maps dont give the extra help just because of players joining late

This commit is contained in:
jenz 2026-04-21 20:00:36 +02:00
parent 2b67f52368
commit 8e46053c0b

View File

@ -3,6 +3,7 @@
#include <mapchooser_extended> #include <mapchooser_extended>
int g_iDoingMapTouristMode; int g_iDoingMapTouristMode;
int g_iActivePlayerCount;
public Plugin myinfo = public Plugin myinfo =
{ {
@ -16,13 +17,34 @@ public Plugin myinfo =
public void OnPluginStart() public void OnPluginStart()
{ {
HookEvent("round_start", OnRoundStart); HookEvent("round_start", OnRoundStart);
CreateTimer(120.0, CheckPopulation, _, TIMER_REPEAT);
g_iDoingMapTouristMode = 0; 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() public void OnPluginEnd()
{ {
ServerCommand("zr_class_set_multiplier zombies knockback 1.0"); ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
g_iDoingMapTouristMode = 0; g_iDoingMapTouristMode = 0;
g_iActivePlayerCount = 0;
} }
public void OnMapEnd() 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("zr_class_set_multiplier zombies knockback 1.0");
ServerCommand("sm_iammo @all 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; int choosen_number = 28;
if (g_iDoingMapTouristMode > active_player_count > 0) if (g_iDoingMapTouristMode > g_iActivePlayerCount > 0)
{ {
CreateTimer(3.0, SetHealthOnCT); 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 zombie_ratio = GetConVarInt(FindConVar("zr_infect_mzombie_ratio"));
int infectectable_players = 0; int infectectable_players = 0;