Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
test
Schema = { rateItems = {} } local function CalcRateArray(array) local array_rates = {} local total_rate = 0 for _, v in ipairs(array) do array_rates[#array_rates + 1] = v[2] total_rate = total_rate + v[2] end array_rates[0] = total_rate for idx = 1, #array_rates do array_rates[idx] = array_rates[idx - 1] + array_rates[idx] / total_rate end Schema.total_rate = total_rate return array_rates end function Schema.GetRandomRateItems() local randf = math.random() for idx = 1, #Schema.rateItems do if (randf < Schema.rateItems[idx][2]) then return Schema.rateItems[idx][1] end end return false end local items = { ['Sword'] = 50, ['Bandage'] = 80, ['Apple'] = 95 } function InitializedPlugins() Schema.rateItems = {} for itemID, v in pairs(items) do Schema.rateItems[#Schema.rateItems + 1] = {itemID, v} end local array_rates = CalcRateArray(Schema.rateItems) for idx = 1, #array_rates do Schema.rateItems[idx] = {Schema.rateItems[idx][1], array_rates[idx]} end array_rates = nil end InitializedPlugins() for k, v in ipairs(Schema.rateItems) do print(k, v[1], v[2]) end
run
|
edit
|
history
|
help
0
xml panel repeater
PAID HACK PuBG
مكسر
Truly random numbers with ranges (Lua)
Weight system (Will make a C# one soon too!)
PAID HACK PuBG
Basic class example
Personal Use (Among Us)
roulette
gdgdf