forked from UNLOZE/sm-plugins
MCE: Adding a timeframe where all map restrictions and CDs are disabled
This commit is contained in:
@@ -160,6 +160,9 @@ ConVar g_Cvar_RandomizeNominations;
|
||||
ConVar g_Cvar_HideTimer;
|
||||
ConVar g_Cvar_NoVoteOption;
|
||||
ConVar g_Cvar_ShufflePerClient;
|
||||
ConVar g_Cvar_NoRestrictionTimeframeEnable;
|
||||
ConVar g_Cvar_NoRestrictionTimeframeMinTime;
|
||||
ConVar g_Cvar_NoRestrictionTimeframeMaxTime;
|
||||
|
||||
/* Mapchooser Extended Data Handles */
|
||||
Handle g_OfficialList = INVALID_HANDLE;
|
||||
@@ -260,6 +263,9 @@ public void OnPluginStart()
|
||||
g_Cvar_HideTimer = CreateConVar("mce_hidetimer", "0", "Hide the MapChooser Extended warning timer", _, true, 0.0, true, 1.0);
|
||||
g_Cvar_NoVoteOption = CreateConVar("mce_addnovote", "1", "Add \"No Vote\" to vote menu?", _, true, 0.0, true, 1.0);
|
||||
g_Cvar_ShufflePerClient = CreateConVar("mce_shuffle_per_client", "1", "Random shuffle map vote menu per client?", _, true, 0.0, true, 1.0);
|
||||
g_Cvar_NoRestrictionTimeframeEnable = CreateConVar("mce_no_restriction_timeframe_enable", "1", "Enable timeframe where all nomination restrictions and cooldowns are disabled?", _, true, 0.0, true, 1.0);
|
||||
g_Cvar_NoRestrictionTimeframeMinTime = CreateConVar("mce_no_restriction_timeframe_mintime", "0100", "Start of the timeframe where all nomination restrictions and cooldowns are disabled (Format: HHMM)", _, true, 0000.0, true, 2359.0);
|
||||
g_Cvar_NoRestrictionTimeframeMaxTime = CreateConVar("mce_no_restriction_timeframe_maxtime", "0700", "End of the timeframe where all nomination restrictions and cooldowns are disabled (Format: HHMM)", _, true, 0000.0, true, 2359.0);
|
||||
|
||||
RegAdminCmd("sm_mapvote", Command_Mapvote, ADMFLAG_CHANGEMAP, "sm_mapvote - Forces MapChooser to attempt to run a map vote now.");
|
||||
RegAdminCmd("sm_setnextmap", Command_SetNextmap, ADMFLAG_CHANGEMAP, "sm_setnextmap <map>");
|
||||
@@ -410,6 +416,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
||||
CreateNative("GetMapGroupRestriction", Native_GetMapGroupRestriction);
|
||||
CreateNative("GetMapVIPRestriction", Native_GetMapVIPRestriction);
|
||||
CreateNative("GetExtendsLeft", Native_GetExtendsLeft);
|
||||
CreateNative("AreRestrictionsActive", Native_AreRestrictionsActive);
|
||||
|
||||
return APLRes_Success;
|
||||
}
|
||||
@@ -514,10 +521,14 @@ public void OnMapEnd()
|
||||
g_RunoffCount = 0;
|
||||
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetCurrentMap(map, PLATFORM_MAX_PATH);
|
||||
int Cooldown;
|
||||
|
||||
int Cooldown = InternalGetMapCooldown(map);
|
||||
g_OldMapList.SetValue(map, Cooldown, true);
|
||||
if(InternalAreRestrictionsActive())
|
||||
{
|
||||
GetCurrentMap(map, PLATFORM_MAX_PATH);
|
||||
Cooldown = InternalGetMapCooldown(map);
|
||||
g_OldMapList.SetValue(map, Cooldown, true);
|
||||
}
|
||||
|
||||
StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot();
|
||||
for(int i = 0; i < OldMapListSnapshot.Length; i++)
|
||||
@@ -1535,7 +1546,7 @@ void CreateNextVote()
|
||||
GetCurrentMap(map, PLATFORM_MAX_PATH);
|
||||
RemoveStringFromArray(tempMaps, map);
|
||||
|
||||
if(GetConVarInt(g_Cvar_ExcludeMaps) && GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps))
|
||||
if((GetConVarInt(g_Cvar_ExcludeMaps) && GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps)) && (InternalAreRestrictionsActive()))
|
||||
{
|
||||
StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot();
|
||||
for(int i = 0; i < OldMapListSnapshot.Length; i++)
|
||||
@@ -1579,6 +1590,13 @@ void CreateNextVote()
|
||||
b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
|
||||
GetArrayString(tempMaps, b, map, PLATFORM_MAX_PATH);
|
||||
|
||||
if(!InternalAreRestrictionsActive())
|
||||
{
|
||||
PushArrayString(g_NextMapList, map);
|
||||
RemoveFromArray(tempMaps, b);
|
||||
break;
|
||||
}
|
||||
|
||||
if(InternalGetMapVIPRestriction(map))
|
||||
continue;
|
||||
|
||||
@@ -1974,6 +1992,9 @@ public int Native_CanNominate(Handle plugin, int numParams)
|
||||
|
||||
public int Native_ExcludeMap(Handle plugin, int numParams)
|
||||
{
|
||||
if(!InternalAreRestrictionsActive())
|
||||
return true;
|
||||
|
||||
int len;
|
||||
GetNativeStringLength(1, len);
|
||||
|
||||
@@ -2219,6 +2240,11 @@ public int Native_GetExtendsLeft(Handle plugin, int numParams)
|
||||
return GetConVarInt(g_Cvar_Extend) - g_Extends;
|
||||
}
|
||||
|
||||
public int Native_AreRestrictionsActive(Handle plugin, int numParams)
|
||||
{
|
||||
return InternalAreRestrictionsActive();
|
||||
}
|
||||
|
||||
stock void AddMapItem(const char[] map)
|
||||
{
|
||||
AddMenuItem(g_VoteMenu, map, map);
|
||||
@@ -2278,6 +2304,9 @@ stock int InternalGetMapCooldown(const char[] map)
|
||||
|
||||
void CheckMapRestrictions(bool time = false, bool players = false)
|
||||
{
|
||||
if(!InternalAreRestrictionsActive())
|
||||
return;
|
||||
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
for(int i = 0; i < GetArraySize(g_NominateList); i++)
|
||||
{
|
||||
@@ -2482,6 +2511,30 @@ stock int InternalGetMapPlayerRestriction(const char[] map)
|
||||
return 0;
|
||||
}
|
||||
|
||||
stock int InternalAreRestrictionsActive()
|
||||
{
|
||||
if (!GetConVarBool(g_Cvar_NoRestrictionTimeframeEnable))
|
||||
return 1;
|
||||
|
||||
char sTime[8];
|
||||
FormatTime(sTime, sizeof(sTime), "%H%M");
|
||||
|
||||
int CurTime = StringToInt(sTime);
|
||||
int MinTime = GetConVarInt(g_Cvar_NoRestrictionTimeframeMinTime);
|
||||
int MaxTime = GetConVarInt(g_Cvar_NoRestrictionTimeframeMaxTime);
|
||||
|
||||
//Wrap around.
|
||||
CurTime = (CurTime <= MinTime) ? CurTime + 2400 : CurTime;
|
||||
MaxTime = (MaxTime <= MinTime) ? MaxTime + 2400 : MaxTime;
|
||||
|
||||
if ((MinTime <= CurTime <= MaxTime))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
stock int FindIntInArray(int[] array, int size, int value)
|
||||
{
|
||||
for(int i = 0; i < size; i++)
|
||||
|
||||
Reference in New Issue
Block a user