• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

help with chanse random

beenii

Well-Known Member
Joined
Jul 26, 2010
Messages
586
Solutions
1
Reaction score
58
i need chanses

for example:

50% chanse obtain 5 to 10
20% chanse obtain 10 to 15
20% chanse obtain 15 to 20
10% chanse obtain 20 to 25

please help with ramdon chanse.
 
Code:
local config = {
    [1] = {chance = 50, min = 5, max = 10}
    [2] = {chance = 20, min = 10, max = 15}
    [3] = {chance = 20, min = 15, max = 20}
    [4] = {chance = 10, min = 20, max = 25}
}

local a = 0
local newtable = {}
for i = 1, #config do
    a = a + config[i].chance
    for j = i, config[i].chance do
        table.insert(newtable, config[i])
    end
end
local rand = math.random(1,a)
local count = math.random(newtable[rand].min, newtable[rand].max)

doPlayerAddItem(cid, 2160, count)
 
work perfect only i add "," hehe for simple error expected (to close '{' at line 20) near '['
Code:
local config = {
    [1] = {chance = 50, min = 5, max = 10},
    [2] = {chance = 20, min = 10, max = 15},
    [3] = {chance = 20, min = 15, max = 20},
    [4] = {chance = 10, min = 20, max = 25}
}

THAKS THANKS.
 
Back
Top