diff --git a/mapchooser_extended/scripting/rockthevote_extended.sp b/mapchooser_extended/scripting/rockthevote_extended.sp index 5d6df9f4..443316b7 100644 --- a/mapchooser_extended/scripting/rockthevote_extended.sp +++ b/mapchooser_extended/scripting/rockthevote_extended.sp @@ -57,6 +57,7 @@ ConVar g_Cvar_InitialDelay; ConVar g_Cvar_Interval; ConVar g_Cvar_ChangeTime; ConVar g_Cvar_RTVPostVoteAction; +ConVar g_Cvar_RTVAutoDisable; bool g_CanRTV = false; // True if RTV loaded maps and is active. bool g_RTVAllowed = false; // True if RTV is available to players. Used to delay rtv votes. @@ -64,6 +65,7 @@ int g_Voters = 0; // Total voters connected. Doesn't include fake clients. int g_Votes = 0; // Total number of "say rtv" votes int g_VotesNeeded = 0; // Necessary votes before map vote begins. (voters * percent_needed) bool g_Voted[MAXPLAYERS+1] = {false, ...}; +Handle g_TimeOverTimer = INVALID_HANDLE; bool g_InChange = false; @@ -79,6 +81,7 @@ public void OnPluginStart() g_Cvar_Interval = CreateConVar("sm_rtv_interval", "240.0", "Time (in seconds) after a failed RTV before another can be held", 0, true, 0.00); g_Cvar_ChangeTime = CreateConVar("sm_rtv_changetime", "0", "When to change the map after a succesful RTV: 0 - Instant, 1 - RoundEnd, 2 - MapEnd", _, true, 0.0, true, 2.0); g_Cvar_RTVPostVoteAction = CreateConVar("sm_rtv_postvoteaction", "0", "What to do with RTV's after a mapvote has completed. 0 - Allow, success = instant change, 1 - Deny", _, true, 0.0, true, 1.0); + g_Cvar_RTVAutoDisable = CreateConVar("sm_rtv_autodisable", "0", "Automatically disable RTV when map time is over.", _, true, 0.0, true, 1.0); RegConsoleCmd("sm_rtv", Command_RTV); @@ -112,6 +115,7 @@ public void OnMapEnd() { g_CanRTV = false; g_RTVAllowed = false; + g_TimeOverTimer = INVALID_HANDLE; } public void OnConfigsExecuted() @@ -119,6 +123,12 @@ public void OnConfigsExecuted() g_CanRTV = true; g_RTVAllowed = false; CreateTimer(g_Cvar_InitialDelay.FloatValue, Timer_DelayRTV, _, TIMER_FLAG_NO_MAPCHANGE); + SetupTimeOverTimer(); +} + +public void OnMapTimeLeftChanged() +{ + SetupTimeOverTimer(); } public void OnClientConnected(int client) @@ -338,3 +348,26 @@ public Action Command_EnableRTV(int client, int args) return Plugin_Handled; } + +void SetupTimeOverTimer() +{ + int time; + if(GetMapTimeLeft(time) && time > 0) + { + if(g_TimeOverTimer != INVALID_HANDLE) + { + KillTimer(g_TimeOverTimer); + g_TimeOverTimer = INVALID_HANDLE; + } + + g_TimeOverTimer = CreateTimer(float(time), Timer_MapOver, _, TIMER_FLAG_NO_MAPCHANGE); + } +} + +public Action Timer_MapOver(Handle timer) +{ + g_TimeOverTimer = INVALID_HANDLE; + + if(g_Cvar_RTVAutoDisable.BoolValue) + g_RTVAllowed = false; +}