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

View File

@ -2,8 +2,11 @@
{
"example_map"
{
"MinPlayers" "25"
"MaxPlayers" "50"
"Cooldown" "20"
"MinTime" "1800"
"MaxTime" "2300"
"MinPlayers" "25"
"MaxPlayers" "50"
"Cooldown" "20"
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -106,16 +106,10 @@
"en" "*{1}"
}
"Map Nominate MinTime Error"
"Map Nominate Time 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}."
"#format" "{1:d},{2:d}"
"en" "You can only nominate this map in {1} hours and {2} minutes."
}
"Map Nominate MinPlayers Error"
@ -132,8 +126,8 @@
"Map Time Restriction"
{
"#format" "{1:s},{2:d}"
"en" "Hours{1}{2}"
"#format" "{1:s},{2:d},{3:d}"
"en" "Time{1}{2}H{3}M"
}
"Map Player Restriction"
@ -142,16 +136,10 @@
"en" "Players{1}{2}"
}
"Nomination Removed MinTime Error"
"Nomination Removed Time 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."
"en" "Your nomination {1} has been removed because it doesn't meet the time requirements."
}
"Nomination Removed MinPlayers Error"