• 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!

Lua Function percent

maikons

Member
Joined
Aug 1, 2015
Messages
227
Reaction score
16
Someone could help me.. I need a percent function to make this
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
  doRemoveItem(item.uid)
   
  light magic missile runes,2287,50%
  intense healing rune,2265,30%
  heavy magic missile runes,2311,10%
  great fireball runes,2304,5%
  explosion rune,2313,3%
  ultimate healing rune,2273,2%
  sudden death rune,2268,1%
  return true
end

On use this item check percent and add item rare or normal...
 
If I understand you correctly you want something like this:
Code:
function chanse(percent)
    return percent >= math.random(1, 100)
end

if chanse(50) then player:addItem(2287, 1) end
if chanse(30) then player:addItem(2265, 1) end
if chanse(10) then player:addItem(2311, 1) end
if chanse(5) then player:addItem(2304, 1) end
if chanse(3) then player:addItem(2313, 1) end
if chanse(2) then player:addItem(2273, 1) end
if chanse(1) then player:addItem(2268, 1) end
 
If I understand you correctly you want something like this:
Code:
function chanse(percent)
    return percent >= math.random(1, 100)
end

if chanse(50) then player:addItem(2287, 1) end
if chanse(30) then player:addItem(2265, 1) end
if chanse(10) then player:addItem(2311, 1) end
if chanse(5) then player:addItem(2304, 1) end
if chanse(3) then player:addItem(2313, 1) end
if chanse(2) then player:addItem(2273, 1) end
if chanse(1) then player:addItem(2268, 1) end
Was that, i needed a random function!
TY!
 
Back
Top