forked from UNLOZE/sm-plugins
Update Mapchooser Time restrictions
Time till nomination calculation might still be off. (restriction itself works fine)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user