Allow mapchooser to exclude maps based on Daytime.
This commit is contained in:
parent
54eca07b3e
commit
9532c0893f
@ -108,8 +108,11 @@ native CanNominateResult CanNominate();
|
|||||||
native bool ExcludeMap(const char[] map, int cooldown = 0, int mode = 0);
|
native bool ExcludeMap(const char[] map, int cooldown = 0, int mode = 0);
|
||||||
|
|
||||||
native int GetMapCooldown(const char[] map);
|
native int GetMapCooldown(const char[] map);
|
||||||
|
native int GetMapMinTime(const char[] map);
|
||||||
|
native int GetMapMaxTime(const char[] map);
|
||||||
native int GetMapMinPlayers(const char[] map);
|
native int GetMapMinPlayers(const char[] map);
|
||||||
native int GetMapMaxPlayers(const char[] map);
|
native int GetMapMaxPlayers(const char[] map);
|
||||||
|
native int GetMapTimeRestriction(const char[] map);
|
||||||
native int GetMapPlayerRestriction(const char[] map);
|
native int GetMapPlayerRestriction(const char[] map);
|
||||||
|
|
||||||
public SharedPlugin __pl_mapchooser_extended =
|
public SharedPlugin __pl_mapchooser_extended =
|
||||||
|
@ -399,8 +399,11 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
|||||||
CreateNative("CanNominate", Native_CanNominate);
|
CreateNative("CanNominate", Native_CanNominate);
|
||||||
CreateNative("ExcludeMap", Native_ExcludeMap);
|
CreateNative("ExcludeMap", Native_ExcludeMap);
|
||||||
CreateNative("GetMapCooldown", Native_GetMapCooldown);
|
CreateNative("GetMapCooldown", Native_GetMapCooldown);
|
||||||
|
CreateNative("GetMapMinTime", Native_GetMapMinTime);
|
||||||
|
CreateNative("GetMapMaxTime", Native_GetMapMaxTime);
|
||||||
CreateNative("GetMapMinPlayers", Native_GetMapMinPlayers);
|
CreateNative("GetMapMinPlayers", Native_GetMapMinPlayers);
|
||||||
CreateNative("GetMapMaxPlayers", Native_GetMapMaxPlayers);
|
CreateNative("GetMapMaxPlayers", Native_GetMapMaxPlayers);
|
||||||
|
CreateNative("GetMapTimeRestriction", Native_GetMapTimeRestriction);
|
||||||
CreateNative("GetMapPlayerRestriction", Native_GetMapPlayerRestriction);
|
CreateNative("GetMapPlayerRestriction", Native_GetMapPlayerRestriction);
|
||||||
|
|
||||||
return APLRes_Success;
|
return APLRes_Success;
|
||||||
@ -544,12 +547,12 @@ public void OnMapEnd()
|
|||||||
|
|
||||||
public void OnClientPutInServer(int client)
|
public void OnClientPutInServer(int client)
|
||||||
{
|
{
|
||||||
CheckMapPlayerRestriction();
|
CheckMapRestrictions(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientDisconnect_Post(int client)
|
public void OnClientDisconnect_Post(int client)
|
||||||
{
|
{
|
||||||
CheckMapPlayerRestriction();
|
CheckMapRestrictions(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientDisconnect(int client)
|
public void OnClientDisconnect(int client)
|
||||||
@ -990,7 +993,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
|
|||||||
if(g_MapVoteCompleted && g_ChangeMapInProgress)
|
if(g_MapVoteCompleted && g_ChangeMapInProgress)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CheckMapPlayerRestriction();
|
CheckMapRestrictions(true, true);
|
||||||
CreateNextVote();
|
CreateNextVote();
|
||||||
|
|
||||||
g_ChangeTime = when;
|
g_ChangeTime = when;
|
||||||
@ -2060,6 +2063,34 @@ public int Native_GetMapCooldown(Handle plugin, int numParams)
|
|||||||
return Cooldown;
|
return Cooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Native_GetMapMinTime(Handle plugin, int numParams)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
GetNativeStringLength(1, len);
|
||||||
|
|
||||||
|
if(len <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char[] map = new char[len+1];
|
||||||
|
GetNativeString(1, map, len+1);
|
||||||
|
|
||||||
|
return InternalGetMapMinTime(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Native_GetMapMaxTime(Handle plugin, int numParams)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
GetNativeStringLength(1, len);
|
||||||
|
|
||||||
|
if(len <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char[] map = new char[len+1];
|
||||||
|
GetNativeString(1, map, len+1);
|
||||||
|
|
||||||
|
return InternalGetMapMaxTime(map);
|
||||||
|
}
|
||||||
|
|
||||||
public int Native_GetMapMinPlayers(Handle plugin, int numParams)
|
public int Native_GetMapMinPlayers(Handle plugin, int numParams)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
@ -2088,6 +2119,20 @@ public int Native_GetMapMaxPlayers(Handle plugin, int numParams)
|
|||||||
return InternalGetMapMaxPlayers(map);
|
return InternalGetMapMaxPlayers(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Native_GetMapTimeRestriction(Handle plugin, int numParams)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
GetNativeStringLength(1, len);
|
||||||
|
|
||||||
|
if(len <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char[] map = new char[len+1];
|
||||||
|
GetNativeString(1, map, len+1);
|
||||||
|
|
||||||
|
return InternalGetMapTimeRestriction(map);
|
||||||
|
}
|
||||||
|
|
||||||
public int Native_GetMapPlayerRestriction(Handle plugin, int numParams)
|
public int Native_GetMapPlayerRestriction(Handle plugin, int numParams)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
@ -2169,7 +2214,7 @@ stock int InternalGetMapCooldown(const char[] map)
|
|||||||
return Cooldown;
|
return Cooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckMapPlayerRestriction()
|
void CheckMapRestrictions(bool time = false, bool players = false)
|
||||||
{
|
{
|
||||||
static char map[PLATFORM_MAX_PATH];
|
static char map[PLATFORM_MAX_PATH];
|
||||||
for(int i = 0; i < GetArraySize(g_NominateList); i++)
|
for(int i = 0; i < GetArraySize(g_NominateList); i++)
|
||||||
@ -2178,9 +2223,38 @@ void CheckMapPlayerRestriction()
|
|||||||
if(CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
if(CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
bool remove;
|
||||||
GetArrayString(g_NominateList, i, map, PLATFORM_MAX_PATH);
|
GetArrayString(g_NominateList, i, map, PLATFORM_MAX_PATH);
|
||||||
int Restriction = InternalGetMapPlayerRestriction(map);
|
|
||||||
if(Restriction)
|
if (time)
|
||||||
|
{
|
||||||
|
int TimeRestriction = InternalGetMapTimeRestriction(map);
|
||||||
|
if(TimeRestriction)
|
||||||
|
{
|
||||||
|
remove = true;
|
||||||
|
|
||||||
|
if(TimeRestriction < 0)
|
||||||
|
CPrintToChat(client, "[MCE] %t", "Nomination Removed MinTime Error", map);
|
||||||
|
else
|
||||||
|
CPrintToChat(client, "[MCE] %t", "Nomination Removed MaxTime Error", map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (players)
|
||||||
|
{
|
||||||
|
int PlayerRestriction = InternalGetMapPlayerRestriction(map);
|
||||||
|
if(PlayerRestriction)
|
||||||
|
{
|
||||||
|
remove = true;
|
||||||
|
|
||||||
|
if(PlayerRestriction < 0)
|
||||||
|
CPrintToChat(client, "[MCE] %t", "Nomination Removed MinPlayers Error", map);
|
||||||
|
else
|
||||||
|
CPrintToChat(client, "[MCE] %t", "Nomination Removed MaxPlayers Error", map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remove)
|
||||||
{
|
{
|
||||||
Call_StartForward(g_NominationsResetForward);
|
Call_StartForward(g_NominationsResetForward);
|
||||||
Call_PushString(map);
|
Call_PushString(map);
|
||||||
@ -2190,15 +2264,36 @@ void CheckMapPlayerRestriction()
|
|||||||
RemoveFromArray(g_NominateList, i);
|
RemoveFromArray(g_NominateList, i);
|
||||||
RemoveFromArray(g_NominateOwners, i);
|
RemoveFromArray(g_NominateOwners, i);
|
||||||
g_NominateCount--;
|
g_NominateCount--;
|
||||||
|
|
||||||
if(Restriction < 0)
|
|
||||||
CPrintToChat(client, "[MCE] %t", "Nomination Removed MinPlayers Error", map);
|
|
||||||
else if(Restriction > 0)
|
|
||||||
CPrintToChat(client, "[MCE] %t", "Nomination Removed MaxPlayers Error", map);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock int InternalGetMapMinTime(const char[] map)
|
||||||
|
{
|
||||||
|
int MinTime = 0;
|
||||||
|
|
||||||
|
if(g_Config && g_Config.JumpToKey(map))
|
||||||
|
{
|
||||||
|
MinTime = g_Config.GetNum("MinTime", MinTime);
|
||||||
|
g_Config.Rewind();
|
||||||
|
}
|
||||||
|
|
||||||
|
return MinTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock int InternalGetMapMaxTime(const char[] map)
|
||||||
|
{
|
||||||
|
int MaxTime = 0;
|
||||||
|
|
||||||
|
if(g_Config && g_Config.JumpToKey(map))
|
||||||
|
{
|
||||||
|
MaxTime = g_Config.GetNum("MaxTime", MaxTime);
|
||||||
|
g_Config.Rewind();
|
||||||
|
}
|
||||||
|
|
||||||
|
return MaxTime;
|
||||||
|
}
|
||||||
|
|
||||||
stock int InternalGetMapMinPlayers(const char[] map)
|
stock int InternalGetMapMinPlayers(const char[] map)
|
||||||
{
|
{
|
||||||
int MinPlayers = 0;
|
int MinPlayers = 0;
|
||||||
@ -2225,6 +2320,27 @@ stock int InternalGetMapMaxPlayers(const char[] map)
|
|||||||
return MaxPlayers;
|
return MaxPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <0 = Less than MinTime
|
||||||
|
// 0 = Okay
|
||||||
|
// >0 = More than MaxTime
|
||||||
|
stock int InternalGetMapTimeRestriction(const char[] map)
|
||||||
|
{
|
||||||
|
char sHour[8];
|
||||||
|
FormatTime(sHour, sizeof(sHour), "%H");
|
||||||
|
|
||||||
|
int CurTime = StringToInt(sHour);
|
||||||
|
int MinTime = InternalGetMapMinTime(map);
|
||||||
|
int MaxTime = InternalGetMapMaxTime(map);
|
||||||
|
|
||||||
|
if(MinTime && CurTime < MinTime)
|
||||||
|
return CurTime - MinTime;
|
||||||
|
|
||||||
|
if(MaxTime && CurTime > MaxTime)
|
||||||
|
return CurTime - MinTime;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// <0 = Less than MinPlayers
|
// <0 = Less than MinPlayers
|
||||||
// 0 = Okay
|
// 0 = Okay
|
||||||
// >0 = More than MaxPlayers
|
// >0 = More than MaxPlayers
|
||||||
|
@ -268,6 +268,17 @@ public Action Command_Addmap(int client, int args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TimeRestriction = GetMapTimeRestriction(mapname);
|
||||||
|
if(TimeRestriction)
|
||||||
|
{
|
||||||
|
if(TimeRestriction < 0)
|
||||||
|
CPrintToChat(client, "[NE] %t", "Map Nominate MinTime Error", TimeRestriction * -1);
|
||||||
|
else
|
||||||
|
CPrintToChat(client, "[NE] %t", "Map Nominate MaxTime Error", TimeRestriction);
|
||||||
|
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||||
if(PlayerRestriction)
|
if(PlayerRestriction)
|
||||||
{
|
{
|
||||||
@ -462,6 +473,17 @@ public Action Command_Nominate(int client, int args)
|
|||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TimeRestriction = GetMapTimeRestriction(mapname);
|
||||||
|
if(TimeRestriction)
|
||||||
|
{
|
||||||
|
if(TimeRestriction < 0)
|
||||||
|
CPrintToChat(client, "[NE] %t", "Map Nominate MinTime Error", TimeRestriction * -1);
|
||||||
|
else
|
||||||
|
CPrintToChat(client, "[NE] %t", "Map Nominate MaxTime Error", TimeRestriction);
|
||||||
|
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||||
if(PlayerRestriction)
|
if(PlayerRestriction)
|
||||||
{
|
{
|
||||||
@ -685,7 +707,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
|||||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||||
return ITEMDRAW_DISABLED;
|
return ITEMDRAW_DISABLED;
|
||||||
|
|
||||||
if(GetMapPlayerRestriction(map))
|
if(GetMapTimeRestriction(map) || GetMapPlayerRestriction(map))
|
||||||
return ITEMDRAW_DISABLED;
|
return ITEMDRAW_DISABLED;
|
||||||
|
|
||||||
return ITEMDRAW_DEFAULT;
|
return ITEMDRAW_DEFAULT;
|
||||||
@ -753,6 +775,17 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TimeRestriction = GetMapTimeRestriction(map);
|
||||||
|
if(TimeRestriction)
|
||||||
|
{
|
||||||
|
if(TimeRestriction < 0)
|
||||||
|
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", TimeRestriction * -1);
|
||||||
|
else
|
||||||
|
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "-", TimeRestriction);
|
||||||
|
|
||||||
|
return RedrawMenuItem(display);
|
||||||
|
}
|
||||||
|
|
||||||
int PlayerRestriction = GetMapPlayerRestriction(map);
|
int PlayerRestriction = GetMapPlayerRestriction(map);
|
||||||
if(PlayerRestriction)
|
if(PlayerRestriction)
|
||||||
{
|
{
|
||||||
@ -850,7 +883,7 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
|||||||
return ITEMDRAW_DISABLED;
|
return ITEMDRAW_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(GetMapPlayerRestriction(map))
|
if(GetMapTimeRestriction(map) || GetMapPlayerRestriction(map))
|
||||||
return ITEMDRAW_DISABLED;
|
return ITEMDRAW_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -894,6 +927,17 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TimeRestriction = GetMapTimeRestriction(map);
|
||||||
|
if(TimeRestriction)
|
||||||
|
{
|
||||||
|
if(TimeRestriction < 0)
|
||||||
|
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", TimeRestriction * -1);
|
||||||
|
else
|
||||||
|
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "-", TimeRestriction);
|
||||||
|
|
||||||
|
return RedrawMenuItem(display);
|
||||||
|
}
|
||||||
|
|
||||||
int PlayerRestriction = GetMapPlayerRestriction(map);
|
int PlayerRestriction = GetMapPlayerRestriction(map);
|
||||||
if(PlayerRestriction)
|
if(PlayerRestriction)
|
||||||
{
|
{
|
||||||
|
@ -106,6 +106,18 @@
|
|||||||
"en" "*{1}"
|
"en" "*{1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Map Nominate MinTime Error"
|
||||||
|
{
|
||||||
|
"#format" "{1:d}"
|
||||||
|
"en" "It's to early to nominate {1}."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Map Nominate MaxTime Error"
|
||||||
|
{
|
||||||
|
"#format" "{1:d}"
|
||||||
|
"en" "It's to late to nominate {1}."
|
||||||
|
}
|
||||||
|
|
||||||
"Map Nominate MinPlayers Error"
|
"Map Nominate MinPlayers Error"
|
||||||
{
|
{
|
||||||
"#format" "{1:d}"
|
"#format" "{1:d}"
|
||||||
@ -118,12 +130,30 @@
|
|||||||
"en" "Map requires {1} less players."
|
"en" "Map requires {1} less players."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Map Time Restriction"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:d}"
|
||||||
|
"en" "Hours{1}{2}"
|
||||||
|
}
|
||||||
|
|
||||||
"Map Player Restriction"
|
"Map Player Restriction"
|
||||||
{
|
{
|
||||||
"#format" "{1:s},{2:d}"
|
"#format" "{1:s},{2:d}"
|
||||||
"en" "Players{1}{2}"
|
"en" "Players{1}{2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Nomination Removed MinTime Error"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Your nomination {1} has been removed because it doesn't meet the minumum time requirements."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Nomination Removed MaxTime Error"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Your nomination {1} has been removed because it exceeds the maximum time restriction."
|
||||||
|
}
|
||||||
|
|
||||||
"Nomination Removed MinPlayers Error"
|
"Nomination Removed MinPlayers Error"
|
||||||
{
|
{
|
||||||
"#format" "{1:s}"
|
"#format" "{1:s}"
|
||||||
|
Loading…
Reference in New Issue
Block a user