Skip to content

Commit

Permalink
Update shavit-timelimit.sp
Browse files Browse the repository at this point in the history
  • Loading branch information
Sirhephaestus authored Sep 28, 2021
1 parent b1a5339 commit 35de5f5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions addons/sourcemod/scripting/shavit-timelimit.sp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ ConVar mp_roundtime = null;
Convar gCV_Config = null;
Convar gCV_DefaultLimit = null;
Convar gCV_DynamicTimelimits = null;
Convar gCV_MinimumLimit = null;
Convar gCV_MaximumLimit = null;
Convar gCV_ForceMapEnd = null;
Convar gCV_MinimumTimes = null;
Convar gCV_PlayerAmount = null;
Expand Down Expand Up @@ -107,6 +109,8 @@ public void OnPluginStart()
gCV_Config = new Convar("shavit_timelimit_config", "1", "Enables the following game settings:\n\"mp_do_warmup_period\" \"0\"\n\"mp_freezetime\" \"0\"\n\"mp_ignore_round_win_conditions\" \"1\"", 0, true, 0.0, true, 1.0);
gCV_DefaultLimit = new Convar("shavit_timelimit_default", "60.0", "Default timelimit to use in case there isn't an average.", 0);
gCV_DynamicTimelimits = new Convar("shavit_timelimit_dynamic", "1", "Use dynamic timelimits.\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
gCV_MinimumLimit = new Convar("shavit_timelimit_minimum", "20.0", "Minimum timelimit to use.\nREQUIRES \"shavit_timelimit_dynamic\" TO BE ENABLED!", 0);
gCV_MaximumLimit = new Convar("shavit_timelimit_maximum", "120.0", "Maximum timelimit to use.\nREQUIRES \"shavit_timelimit_dynamic\" TO BE ENABLED!\n0 - No maximum", 0);
gCV_ForceMapEnd = new Convar("shavit_timelimit_forcemapend", "1", "Force the map to end after the timelimit.\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
gCV_MinimumTimes = new Convar("shavit_timelimit_minimumtimes", "5", "Minimum amount of times required to calculate an average.\nREQUIRES \"shavit_timelimit_dynamic\" TO BE ENABLED!", 0, true, 5.0);
gCV_PlayerAmount = new Convar("shavit_timelimit_playertime", "25", "Limited amount of times to grab from the database to calculate an average.\nREQUIRES \"shavit_timelimit_dynamic\" TO BE ENABLED!\nSet to 0 to have it \"unlimited\".", 0);
Expand Down Expand Up @@ -245,17 +249,17 @@ public void SQL_GetMapTimes(Database db, DBResultSet results, const char[] error

fAverage += 5; // I give extra 5 minutes, so players can actually retry the map until they get a good time.

if(fAverage < 20)
if(fAverage < gCV_MinimumLimit.FloatValue)
{
fAverage = 20.0;
fAverage = gCV_MinimumLimit.FloatValue;
}

else if(fAverage > 120)
else if(fAverage > gCV_MaximumLimit.FloatValue)
{
fAverage = 120.0;
fAverage = gCV_MaximumLimit.FloatValue;
}

SetLimit(RoundToNearest(fAverage));
SetLimit(RoundToCeil(fAverage / 10) * 10);
}

else
Expand Down

0 comments on commit 35de5f5

Please sign in to comment.