Update Mapchooser Time restrictions

Time till nomination calculation might still be off. (restriction itself
works fine)
This commit is contained in:
zaCade
2017-10-15 16:20:53 +02:00
parent b92e95b79e
commit 6fc8146d7f
4 changed files with 43 additions and 51 deletions
@@ -2233,10 +2233,7 @@ void CheckMapRestrictions(bool time = false, bool players = false)
{
remove = true;
if(TimeRestriction < 0)
CPrintToChat(client, "[MCE] %t", "Nomination Removed MinTime Error", map);
else
CPrintToChat(client, "[MCE] %t", "Nomination Removed MaxTime Error", map);
CPrintToChat(client, "[MCE] %t", "Nomination Removed Time Error", map);
}
}
@@ -2320,23 +2317,39 @@ stock int InternalGetMapMaxPlayers(const char[] map)
return MaxPlayers;
}
// <0 = Less than MinTime
// 0 = Okay
// >0 = More than MaxTime
// >0 = Minutes till Okay
stock int InternalGetMapTimeRestriction(const char[] map)
{
char sHour[8];
FormatTime(sHour, sizeof(sHour), "%H");
char sTime[8];
FormatTime(sTime, sizeof(sTime), "%H%M");
int CurTime = StringToInt(sHour);
int CurTime = StringToInt(sTime);
int MinTime = InternalGetMapMinTime(map);
int MaxTime = InternalGetMapMaxTime(map);
if(MinTime && CurTime < MinTime)
return CurTime - MinTime;
// Wrap around if max is less then min.
if (MaxTime <= MinTime)
{
MaxTime += 2400;
if(MaxTime && CurTime > MaxTime)
return CurTime - MaxTime;
if (CurTime <= MinTime)
CurTime += 2400;
}
if (!(MinTime <= CurTime <= MaxTime))
{
// Wrap around if min is less then current.
if (MinTime <= CurTime)
MinTime += 2400;
// Convert our 'time' to minutes;
CurTime = (RoundToFloor(float(CurTime / 100)) * 60) + (CurTime % 100);
MinTime = (RoundToFloor(float(MinTime / 100)) * 60) + (MinTime % 100);
MaxTime = (RoundToFloor(float(MaxTime / 100)) * 60) + (MaxTime % 100);
return MinTime - CurTime;
}
return 0;
}
@@ -271,10 +271,7 @@ 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);
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
return Plugin_Handled;
}
@@ -476,10 +473,7 @@ public Action Command_Nominate(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);
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
return Plugin_Handled;
}
@@ -778,10 +772,7 @@ 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);
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
return RedrawMenuItem(display);
}
@@ -930,10 +921,7 @@ 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);
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
return RedrawMenuItem(display);
}