TeamManager: add max timer
This commit is contained in:
parent
27ae71dd4e
commit
6e36e86b44
@ -7,9 +7,11 @@
|
|||||||
#define MIN_PLAYERS 2
|
#define MIN_PLAYERS 2
|
||||||
|
|
||||||
int g_iWarmup = 0;
|
int g_iWarmup = 0;
|
||||||
|
int g_iMaxWarmup = 0;
|
||||||
bool g_bWarmup = false;
|
bool g_bWarmup = false;
|
||||||
ConVar g_CVar_sm_warmuptime;
|
ConVar g_CVar_sm_warmuptime;
|
||||||
ConVar g_CVar_sm_warmupratio;
|
ConVar g_CVar_sm_warmupratio;
|
||||||
|
ConVar g_CVar_sm_warmupmaxtime;
|
||||||
|
|
||||||
bool g_bRoundEnded = false;
|
bool g_bRoundEnded = false;
|
||||||
bool g_bZombieSpawned = false;
|
bool g_bZombieSpawned = false;
|
||||||
@ -35,6 +37,7 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
g_CVar_sm_warmuptime = CreateConVar("sm_warmuptime", "10", "Warmup timer.", 0, true, 0.0, true, 60.0);
|
g_CVar_sm_warmuptime = CreateConVar("sm_warmuptime", "10", "Warmup timer.", 0, true, 0.0, true, 60.0);
|
||||||
g_CVar_sm_warmupratio = CreateConVar("sm_warmupratio", "0.60", "Ratio of connected players that need to be in game to start warmup timer.", 0, true, 0.0, true, 1.0);
|
g_CVar_sm_warmupratio = CreateConVar("sm_warmupratio", "0.60", "Ratio of connected players that need to be in game to start warmup timer.", 0, true, 0.0, true, 1.0);
|
||||||
|
g_CVar_sm_warmupmaxtime = CreateConVar("sm_warmupmaxtime", "45", "Max Warmup timer.", 0, true, 0.0, true, 120.0);
|
||||||
|
|
||||||
AutoExecConfig(true, "plugin.TeamManager");
|
AutoExecConfig(true, "plugin.TeamManager");
|
||||||
}
|
}
|
||||||
@ -55,19 +58,12 @@ public void OnMapStart()
|
|||||||
|
|
||||||
public Action OnWarmupTimer(Handle timer)
|
public Action OnWarmupTimer(Handle timer)
|
||||||
{
|
{
|
||||||
if(g_CVar_sm_warmupratio.FloatValue > 0.0)
|
if(g_iMaxWarmup >= g_CVar_sm_warmupmaxtime.IntValue)
|
||||||
{
|
{
|
||||||
int ClientsConnected = GetClientCount(false);
|
g_iMaxWarmup = 0;
|
||||||
int ClientsInGame = GetClientCount(true);
|
g_bWarmup = false;
|
||||||
int ClientsNeeded = RoundToCeil(float(ClientsConnected) * g_CVar_sm_warmupratio.FloatValue);
|
CS_TerminateRound(3.0, CSRoundEnd_GameStart, false);
|
||||||
ClientsNeeded = ClientsNeeded > MIN_PLAYERS ? ClientsNeeded : MIN_PLAYERS;
|
return Plugin_Stop;
|
||||||
|
|
||||||
if(ClientsInGame < ClientsNeeded)
|
|
||||||
{
|
|
||||||
g_iWarmup = 0;
|
|
||||||
PrintCenterTextAll("Warmup: Waiting for %d more players to join.", ClientsNeeded - ClientsInGame);
|
|
||||||
return Plugin_Continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_iWarmup >= g_CVar_sm_warmuptime.IntValue)
|
if(g_iWarmup >= g_CVar_sm_warmuptime.IntValue)
|
||||||
@ -78,8 +74,27 @@ public Action OnWarmupTimer(Handle timer)
|
|||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintCenterTextAll("Warmup: %d", g_CVar_sm_warmuptime.IntValue - g_iWarmup);
|
if(g_CVar_sm_warmupratio.FloatValue > 0.0)
|
||||||
g_iWarmup++;
|
{
|
||||||
|
int ClientsConnected = GetClientCount(false);
|
||||||
|
int ClientsInGame = GetClientCount(true);
|
||||||
|
int ClientsNeeded = RoundToCeil(float(ClientsConnected) * g_CVar_sm_warmupratio.FloatValue);
|
||||||
|
ClientsNeeded = ClientsNeeded > MIN_PLAYERS ? ClientsNeeded : MIN_PLAYERS;
|
||||||
|
|
||||||
|
if(ClientsInGame < ClientsNeeded)
|
||||||
|
{
|
||||||
|
g_iWarmup = 0;
|
||||||
|
g_iMaxWarmup++;
|
||||||
|
PrintCenterTextAll("Warmup: Waiting for %d more players to join or %d seconds.", ClientsNeeded - ClientsInGame, g_CVar_sm_warmupmaxtime.IntValue - g_iMaxWarmup);
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
else if(ClientsInGame >= ClientsNeeded)
|
||||||
|
{
|
||||||
|
g_iWarmup++;
|
||||||
|
PrintCenterTextAll("Warmup: Enough players joined. %d seconds left. ", g_CVar_sm_warmuptime.IntValue - g_iWarmup);
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user