local avgTime = 0
local varTime = 0
function calledWhenRaceStarts()
if mysql_query(handler, "SELECT COUNT(*) FROM tops WHERE this_is_this_map") == 0 then
avgTime = 0
varTime = 0
return
end
local result = mysql_query(handler, "SELECT AVG(time) FROM tops WHERE this_is_this_map")
avgTime = toNumber(result)
local result = mysql_query(handler, "SELECT VAR(time) FROM tops WHERE this_is_this_map")
varTime = toNumber(result)
end
local A = 1
function calculatePoints(rank, pc, mode)
if not pc then pc = g_playerCount end
if not mode then mode = g_mode end
local points
if mode == 1 or mode == 3 then -- Race or DM
if (avgTime == 0 or varTime == 0)
points = A
else
points = A * exp((time - avgTim)^2 / (2 * varTime))
end
elseif mode == 2 then -- DD
points = A * 1000 * math.floor(pc - rank)
end
return points
end
function calculateMoney(rank, pc, mode)
if not pc then pc = g_playerCount end
if not mode then mode = g_mode end
local money = 0
if mode == 1 or mode == 3 then -- Race or DM
money = (1 - rank/pc) * log(pc)
elseif mode == 2 then -- DD
money = (1 - rank/pc) * pc ^ (1/2)
end
return money
end
{"text":"text","html5":"html","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"lua","bash":"sh","erlang":"erlang","go":"golang","c":"c_cpp","cpp":"c_cpp","diff":"diff","latex":"latex","sql":"sql","xml":"xml","0":"text","abap":"abap","actionscript":"actionscript","actionscript3":"actionscript","ada":"ada","apache":"apache_conf","applescript":"applescript","asm":"assembly_x86","autohotkey":"autohotkey","closure":"closure","cobol":"cobol","coffeescript":"coffee","cpp-winapi":"c_cpp","c_loadrunner":"c_cpp","c_mac":"c_cpp","c_winapi":"c_cpp","csharp":"csharp","d":"d","dart":"dart","dot":"dot","eiffel":"eiffel","fortran":"fortran","groovy":"groovy","haskell":"haskell","haxe":"haxe","ini":"ini","io":"io","java":"java","java5":"java","make":"makefile","matlab":"matlab","mysql":"mysql","objc":"objectivec","ocaml":"ocaml","pascal":"pascal","perl":"perl","perl6":"perl","postgresql":"pgsql","powershell":"powershell","prolog":"prolog","properties":"properties","rails":"ruby","rust":"rust","scala":"scala","scheme":"scheme","smarty":"smarty","tcl":"tcl","vala":"vala","vb":"vbscript","verilog":"verilog","vhdl":"vhdl","yaml":"yaml"}