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

[Function] To sort numbers with chance

perdigs

New Member
Joined
Aug 22, 2010
Messages
114
Reaction score
1
Code:
function getSuccess(chanceNumber, chanceMultiplier, Chances, finalNum)

  for cN = 1, (chanceNumber *chanceMultiplier) do
  chanceNumbers = {}
      addEvent(table.insert, 0*cN, chanceNumbers, math.random(1, Chances))
  end
   
  for check = 1, table.maxn(chanceNumbers) do
  compare = {}    
  if chanceNumbers[check] == finalNum then
     table.insert(compare, chanceNumbers[check])
  end
  end
  if table.maxn(compare) >= 1 then
  return TRUE
  else
  return FALSE
  end 
end

Well I will explain my script, we assume that the numbers between 1 and 2500 (Chances) I have a chance of 50 (chanceNumber) randomized numbers succeed to reach the number 250 (finalNum) drawn between the numbers who said in early 1-2500 (Chances).
Create this script based on that, but it did not work the way I like, I'm not very good with tables where the script enters numbers on them and I am still learning in this regard.
I would like your help so that I can create a script that does this function.
I appreciate the help already.
Thank you.
 
Code:
function getSuccess(minValue, maxValue, tries, answer)
   for x = 1, tries, 1 do
      if(math.random(minValue, maxValue) == answer) then
         return true
      end
   end
   return false
end

this should be what you want, it generates "tries" numbers, if one of the numbers generated between "minValue" and "maxValue" is "answer", it returns true, otherwise returns false.
 
I don't see a use for this.
Instead of trying to roll math.random(1, 10) 5 times you could just check once for math.random(1, 2) etc.
 
Back
Top