Merge remote-tracking branch 'old/master'
This commit is contained in:
@@ -6,12 +6,12 @@
|
||||
|
||||
#define MIN_PLAYERS 2
|
||||
|
||||
Handle g_hWarmupEndFwd;
|
||||
|
||||
int g_iWarmup = 0;
|
||||
int g_iMaxWarmup = 0;
|
||||
bool g_bWarmup = false;
|
||||
ConVar g_CVar_sm_warmuptime;
|
||||
ConVar g_CVar_sm_warmupratio;
|
||||
ConVar g_CVar_sm_warmupmaxtime;
|
||||
|
||||
bool g_bRoundEnded = false;
|
||||
bool g_bZombieSpawned = false;
|
||||
@@ -26,15 +26,6 @@ public Plugin myinfo =
|
||||
url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/TeamManager"
|
||||
};
|
||||
|
||||
public APLRes AskPluginLoad2(Handle hThis, bool bLate, char[] err, int iErrLen)
|
||||
{
|
||||
CreateNative("TeamManager_InWarmup", Native_InWarmup);
|
||||
|
||||
RegPluginLibrary("TeamManager");
|
||||
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
if (GetEngineVersion() == Engine_CSGO)
|
||||
@@ -46,8 +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_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_hWarmupEndFwd = CreateGlobalForward("TeamManager_WarmupEnd", ET_Ignore);
|
||||
g_CVar_sm_warmupmaxtime = CreateConVar("sm_warmupmaxtime", "45", "Max Warmup timer.", 0, true, 0.0, true, 120.0);
|
||||
|
||||
AutoExecConfig(true, "plugin.TeamManager");
|
||||
}
|
||||
@@ -55,6 +45,7 @@ public void OnPluginStart()
|
||||
public void OnMapStart()
|
||||
{
|
||||
g_iWarmup = 0;
|
||||
g_iMaxWarmup = 0;
|
||||
g_bWarmup = false;
|
||||
g_bRoundEnded = false;
|
||||
g_bZombieSpawned = false;
|
||||
@@ -68,6 +59,22 @@ public void OnMapStart()
|
||||
|
||||
public Action OnWarmupTimer(Handle timer)
|
||||
{
|
||||
if(g_iMaxWarmup >= g_CVar_sm_warmupmaxtime.IntValue)
|
||||
{
|
||||
g_iMaxWarmup = 0;
|
||||
g_bWarmup = false;
|
||||
CS_TerminateRound(3.0, CSRoundEnd_GameStart, false);
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
if(g_iWarmup >= g_CVar_sm_warmuptime.IntValue)
|
||||
{
|
||||
g_iWarmup = 0;
|
||||
g_bWarmup = false;
|
||||
CS_TerminateRound(3.0, CSRoundEnd_GameStart, false);
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
if(g_CVar_sm_warmupratio.FloatValue > 0.0)
|
||||
{
|
||||
int ClientsConnected = GetClientCount(false);
|
||||
@@ -77,35 +84,21 @@ public Action OnWarmupTimer(Handle timer)
|
||||
|
||||
if(ClientsInGame < ClientsNeeded)
|
||||
{
|
||||
g_iWarmup = 0;
|
||||
PrintCenterTextAll("Warmup: Waiting for %d more players to join.", ClientsNeeded - ClientsInGame);
|
||||
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
|
||||
{
|
||||
g_iWarmup++;
|
||||
PrintCenterTextAll("Warmup: Enough players joined. %d seconds left. ", g_CVar_sm_warmuptime.IntValue - g_iWarmup);
|
||||
return Plugin_Continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(g_iWarmup >= g_CVar_sm_warmuptime.IntValue)
|
||||
{
|
||||
g_iWarmup = 0;
|
||||
g_bWarmup = false;
|
||||
float fDelay = 3.0;
|
||||
CS_TerminateRound(fDelay, CSRoundEnd_GameStart, false);
|
||||
CreateTimer(fDelay, Timer_FireForward, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
PrintCenterTextAll("Warmup: %d", g_CVar_sm_warmuptime.IntValue - g_iWarmup);
|
||||
g_iWarmup++;
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action Timer_FireForward(Handle hThis)
|
||||
{
|
||||
Call_StartForward(g_hWarmupEndFwd);
|
||||
Call_Finish();
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_TeamChangeQueue[client] = -1;
|
||||
@@ -227,7 +220,10 @@ public Action ZR_OnClientInfect(int &client, int &attacker, bool &motherInfect,
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public int Native_InWarmup(Handle hPlugin, int numParams)
|
||||
public Action ZR_OnInfectCountdown()
|
||||
{
|
||||
return g_bWarmup;
|
||||
if(g_bWarmup)
|
||||
return Plugin_Handled;
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user