Re: calculate

From Voluminous Wolf, 10 Years ago, written in Lua, viewed 783 times. This paste is a reply to calculate from Crys - go back
URL https://paste.godclan.hu/view/_Gheir-3/diff Embed
Viewing differences between calculate and Re: calculate
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
        
Race or DM
        if (avgTime == 0 or varTime == 0)
            
points = math.floor(pc A
        else
            points = A * exp((time 
rank)
avgTim)^2 / (2 * varTime))
        end
    elseif mode == 2 then -- DD
        points = A * 1000 * math.floor(pc - rank)
    elseif mode == 3 then -- DM\n        points = math.floor(pc - rank)\n    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
    
money = 0
    
if mode == 1 or mode == 3 then -- Race
        
Race or DM
        
money = (pc (1 rank) rank/pc) 250
log(pc)
    elseif mode == 2 then -- DD
        money = (pc (1 rank) rank/pc) 250
    elseif mode == 3 then -- DM
        money = (pc - rank) * 250
pc ^ (1/2)
    end
    return money
end

Reply to "Re: calculate"

Here you can reply to the paste above