diff --git a/mapchooser_extended/scripting/mapchooser_extended.sp b/mapchooser_extended/scripting/mapchooser_extended.sp index 26577c96..4e57c0f0 100644 --- a/mapchooser_extended/scripting/mapchooser_extended.sp +++ b/mapchooser_extended/scripting/mapchooser_extended.sp @@ -237,7 +237,7 @@ public void OnPluginStart() g_Cvar_ExtendTimeStep = CreateConVar("mce_extend_timestep", "15", "Specifies how much many more minutes each extension makes", _, true, 5.0); g_Cvar_ExtendRoundStep = CreateConVar("mce_extend_roundstep", "5", "Specifies how many more rounds each extension makes", _, true, 1.0); g_Cvar_ExtendFragStep = CreateConVar("mce_extend_fragstep", "10", "Specifies how many more frags are allowed when map is extended.", _, true, 5.0); - g_Cvar_ExcludeMaps = CreateConVar("mce_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0); + g_Cvar_ExcludeMaps = CreateConVar("mce_exclude", "5", "Specifies for how many hours past maps should be excluded from the vote.", _, true, 0.0); g_Cvar_IncludeMaps = CreateConVar("mce_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 7.0); g_Cvar_IncludeMapsReserved = CreateConVar("mce_include_reserved", "2", "Specifies how many private/random maps to include in the vote.", _, true, 0.0, true, 5.0); g_Cvar_NoVoteMode = CreateConVar("mce_novote", "1", "Specifies whether or not MapChooser should pick a map if no votes are received.", _, true, 0.0, true, 1.0); @@ -378,6 +378,8 @@ public void OnPluginStart() g_MapVoteRunoffStartForward = CreateGlobalForward("OnMapVoteRunnoffWarningStart", ET_Ignore); InternalRestoreMapCooldowns(); + + CreateTimer(60.0, UpdateCooldowns, INVALID_HANDLE, TIMER_REPEAT); } public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) @@ -526,15 +528,20 @@ public void OnMapEnd() g_WarningTimer = INVALID_HANDLE; g_RunoffCount = 0; - static char map[PLATFORM_MAX_PATH]; - int Cooldown; - if(g_SaveCDOnMapEnd) { + static char map[PLATFORM_MAX_PATH]; GetCurrentMap(map, PLATFORM_MAX_PATH); - Cooldown = InternalGetMapCooldown(map); + int Cooldown = InternalGetMapCooldown(map); g_OldMapList.SetValue(map, Cooldown, true); + InternalStoreMapCooldowns(); } +} + +public Action UpdateCooldowns(Handle timer) +{ + static char map[PLATFORM_MAX_PATH]; + int Cooldown; StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot(); for(int i = 0; i < OldMapListSnapshot.Length; i++) @@ -542,7 +549,7 @@ public void OnMapEnd() OldMapListSnapshot.GetKey(i, map, sizeof(map)); g_OldMapList.GetValue(map, Cooldown); - Cooldown--; + Cooldown --; if(Cooldown > 0) g_OldMapList.SetValue(map, Cooldown, true); else @@ -2301,7 +2308,7 @@ stock int InternalGetMapCooldown(const char[] map) g_Config.Rewind(); } - return Cooldown; + return RoundToNearest(Cooldown * 60.0); } void CheckMapRestrictions(bool time = false, bool players = false) diff --git a/mapchooser_extended/scripting/nominations_extended.sp b/mapchooser_extended/scripting/nominations_extended.sp index b6d039a5..933d9874 100644 --- a/mapchooser_extended/scripting/nominations_extended.sp +++ b/mapchooser_extended/scripting/nominations_extended.sp @@ -118,6 +118,8 @@ public void OnPluginStart() CreateConVar("ne_version", MCE_VERSION, "Nominations Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD); g_mapTrie = CreateTrie(); + + CreateTimer(60.0, ForceUpdate, INVALID_HANDLE, TIMER_REPEAT); } public APLRes AskPluginLoad2(Handle hThis, bool bLate, char[] err, int iErrLen) @@ -239,6 +241,11 @@ void UpdateMapTrie() delete excludeMaps; } +public Action ForceUpdate(Handle timer) +{ + UpdateMapTrie(); +} + public void OnNominationRemoved(const char[] map, int owner) { int status; @@ -291,7 +298,9 @@ public Action Command_Addmap(int client, int args) if((status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS) { int Cooldown = GetMapCooldown(mapname); - CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown); + int ConvertedCooldown[2]; + ConvertCooldown(Cooldown, ConvertedCooldown); + CPrintToChat(client, "[NE] %T", "Map Nominate Cooldown Error", client, ConvertedCooldown[0], ConvertedCooldown[1]); } if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED) @@ -385,7 +394,7 @@ public Action Command_AddExclude(int client, int args) { if(args < 1) { - CReplyToCommand(client, "[NE] Usage: sm_nominate_exclude "); + CReplyToCommand(client, "[NE] Usage: sm_nominate_exclude [cooldown (minutes)] [mode]"); return Plugin_Handled; } @@ -501,7 +510,9 @@ public Action Command_Nominate(int client, int args) if(((status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS) && AreRestrictionsActive()) { int Cooldown = GetMapCooldown(mapname); - CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown); + int ConvertedCooldown[2]; + ConvertCooldown(Cooldown, ConvertedCooldown); + CPrintToChat(client, "[NE] %T", "Map Nominate Cooldown Error", client, ConvertedCooldown[0], ConvertedCooldown[1]); } if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED) @@ -874,7 +885,9 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p if(((status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS) && AreRestrictionsActive()) { int Cooldown = GetMapCooldown(map); - Format(display, sizeof(display), "%s (%T %d)", buffer, "Recently Played", param1, Cooldown); + int ConvertedCooldown[2]; + ConvertCooldown(Cooldown, ConvertedCooldown); + Format(display, sizeof(display), "%s (%T)", buffer, "Map Cooldown", param1, ConvertedCooldown[0], ConvertedCooldown[1]); return RedrawMenuItem(display); } @@ -1050,7 +1063,9 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1, if((status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS) { int Cooldown = GetMapCooldown(map); - Format(display, sizeof(display), "%s (%T %d)", buffer, "Recently Played", param1, Cooldown); + int ConvertedCooldown[2]; + ConvertCooldown(Cooldown, ConvertedCooldown); + Format(display, sizeof(display), "%s (%T)", buffer, "Map Cooldown", param1, ConvertedCooldown[0], ConvertedCooldown[1]); return RedrawMenuItem(display); } @@ -1214,3 +1229,9 @@ stock int GetVIPTimeRestriction() return 0; } + +stock void ConvertCooldown(int Cooldown, int Time[2]) +{ + Time[0] = Cooldown / 60; + Time[1] = Cooldown - (Time[0] * 60); +} diff --git a/mapchooser_extended/translations/mapchooser_extended.phrases.txt b/mapchooser_extended/translations/mapchooser_extended.phrases.txt index 07ad85a4..e252fd61 100644 --- a/mapchooser_extended/translations/mapchooser_extended.phrases.txt +++ b/mapchooser_extended/translations/mapchooser_extended.phrases.txt @@ -111,9 +111,15 @@ "en" "VIP Nomination" } + "Map Nominate Cooldown Error" + { + "#format" "{1:d},{2:d}" + "en" "You need to wait {1} hours and {2} minutes for the map to come off cooldown." + } + "Map Nominate VIP Error" { - "en" "Only VIPs can nominate this map." + "en" "You need to be VIP to nominate this map." } "Map Nominate Time Error" @@ -140,6 +146,12 @@ "en" "The maximum amount ({1}) of maps from this group has already been nominated." } + "Map Cooldown" + { + "#format" "{1:d},{2:d}" + "en" "Cooldown: {1}H{2}M" + } + "Map Time Restriction" { "#format" "{1:s},{2:d},{3:d}"