mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 02:18:26 +00:00
Add enabled convar for shavit-timelimit
This commit is contained in:
parent
65f9f8da4a
commit
697cb409f1
@ -53,6 +53,7 @@ Convar gCV_MinimumTimes = null;
|
||||
Convar gCV_PlayerAmount = null;
|
||||
Convar gCV_Style = null;
|
||||
Convar gCV_GameStartFix = null;
|
||||
Convar gCV_Enabled = null;
|
||||
|
||||
// misc cache
|
||||
Handle gH_Timer = null;
|
||||
@ -103,8 +104,10 @@ public void OnPluginStart()
|
||||
gCV_PlayerAmount = new Convar("shavit_timelimit_playertime", "25", "Limited amount of times to grab from the database to calculate an average.\nREQUIRES \"shavit_timelimit_dynamic\" TO BE ENABLED!\nSet to 0 to have it \"unlimited\".", 0);
|
||||
gCV_Style = new Convar("shavit_timelimit_style", "1", "If set to 1, calculate an average only from times that the first (default: forwards) style was used to set.\nREQUIRES \"shavit_timelimit_dynamic\" TO BE ENABLED!", 0, true, 0.0, true, 1.0);
|
||||
gCV_GameStartFix = new Convar("shavit_timelimit_gamestartfix", "1", "If set to 1, will block the round from ending because another player joined. Useful for single round servers.", 0, true, 0.0, true, 1.0);
|
||||
gCV_Enabled = new Convar("shavit_timelimit_enabled", "1", "Enables/Disables functionality of the plugin.", 0, true, 0.0, true, 1.0);
|
||||
|
||||
gCV_ForceMapEnd.AddChangeHook(OnConVarChanged);
|
||||
gCV_Enabled.AddChangeHook(OnConVarChanged);
|
||||
|
||||
Convar.AutoExecConfig();
|
||||
|
||||
@ -116,7 +119,8 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
|
||||
{
|
||||
if(view_as<bool>(StringToInt(newValue)) && gEV_Type != Engine_TF2)
|
||||
{
|
||||
gH_Timer = CreateTimer(1.0, Timer_PrintToChat, 0, TIMER_REPEAT);
|
||||
delete gH_Timer;
|
||||
gH_Timer = CreateTimer(1.0, Timer_PrintToChat, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
else
|
||||
@ -127,6 +131,11 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
|
||||
|
||||
public void OnConfigsExecuted()
|
||||
{
|
||||
if(!gCV_Enabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(gCV_Config.BoolValue)
|
||||
{
|
||||
if(mp_do_warmup_period != null)
|
||||
@ -144,10 +153,7 @@ public void OnConfigsExecuted()
|
||||
mp_ignore_round_win_conditions.BoolValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
if(gCV_DynamicTimelimits.BoolValue)
|
||||
{
|
||||
StartCalculating();
|
||||
@ -255,6 +261,11 @@ void SetLimit(int time)
|
||||
|
||||
public Action Timer_PrintToChat(Handle timer)
|
||||
{
|
||||
if(!gCV_Enabled.BoolValue)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
int timelimit = 0;
|
||||
|
||||
if(!GetMapTimeLimit(timelimit) || timelimit == 0)
|
||||
@ -308,9 +319,9 @@ public Action Timer_PrintToChat(Handle timer)
|
||||
|
||||
public Action CS_OnTerminateRound(float &fDelay, CSRoundEndReason &iReason)
|
||||
{
|
||||
if(gCV_GameStartFix.BoolValue && iReason == CSRoundEnd_GameStart)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
if(gCV_Enabled.BoolValue && gCV_GameStartFix.BoolValue && iReason == CSRoundEnd_GameStart)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user