From 487d3e4a9cae6403364006e16df37f529131620e Mon Sep 17 00:00:00 2001 From: shavit Date: Thu, 27 Dec 2018 06:14:33 +0200 Subject: [PATCH] Added shavit_rankings_weighting because y'all complain about rankings --- addons/sourcemod/scripting/shavit-rankings.sp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/sourcemod/scripting/shavit-rankings.sp b/addons/sourcemod/scripting/shavit-rankings.sp index b08ce658..259a7372 100644 --- a/addons/sourcemod/scripting/shavit-rankings.sp +++ b/addons/sourcemod/scripting/shavit-rankings.sp @@ -66,6 +66,9 @@ StringMap gA_MapTiers = null; ConVar gCV_PointsPerTier = null; float gF_PointsPerTier = 50.0; +ConVar gCV_WeightingMultiplier = null; +float gF_WeightingMultiplier = 0.975; + int gI_Rank[MAXPLAYERS+1]; float gF_Points[MAXPLAYERS+1]; @@ -144,6 +147,9 @@ public void OnPluginStart() gCV_PointsPerTier = CreateConVar("shavit_rankings_pointspertier", "50.0", "Base points to use for per-tier scaling.\nRead the design idea to see how it works: https://github.com/shavitush/bhoptimer/issues/465", 0, true, 1.0); gCV_PointsPerTier.AddChangeHook(OnConVarChanged); + gCV_WeightingMultiplier = CreateConVar("shavit_rankings_weighting", "0.975", "Weighing multiplier. 1.0 to disable weighting.\nFormula: p[1] * this^0 + p[2] * this^1 + p[3] * this^2 + ... + p[n] * this^(n-1)\nRestart server to apply.", 0, true, 0.01, true, 1.0); + gCV_WeightingMultiplier.AddChangeHook(OnConVarChanged); + AutoExecConfig(); LoadTranslations("common.phrases"); @@ -320,11 +326,11 @@ public void SQL_CreateTable_Callback(Database db, DBResultSet results, const cha "LEAVE iter; " ... "END IF; " ... "SET total = total + (p * mult); " ... - "SET mult = mult * 0.975; " ... + "SET mult = mult * %f; " ... "END LOOP; " ... "CLOSE cur; " ... "RETURN total; " ... - "END;;", gS_MySQLPrefix); + "END;;", gS_MySQLPrefix, gF_WeightingMultiplier); RunLongFastQuery(bSuccess, "CREATE GetRecordPoints", "CREATE FUNCTION GetRecordPoints(rstyle INT, rtrack INT, rtime FLOAT, rmap CHAR(128), pointspertier FLOAT, stylemultiplier FLOAT) " ... @@ -380,6 +386,7 @@ void RunLongFastQuery(bool &success, const char[] func, const char[] query, any public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue) { gF_PointsPerTier = gCV_PointsPerTier.FloatValue; + gF_WeightingMultiplier = gCV_WeightingMultiplier.FloatValue; } public void OnClientConnected(int client)