Chances

Discussion in 'Spigot Plugin Development' started by Creepermanthe3rd, May 31, 2017.

  1. Im working on a private plugin for a crate you get for mining and when you get it and click it you get a reward. Ive got it all done besides the giviing away item part. I have about 15ish items some of the chances will be decimals some will be ints, So what would be the best way to do that?
     
  2. Use Math.Random() to generate a decimal between 0 and 1. Then simply for each item check the percentage you want. Eg. If x * 100 > y then do z
     
    • Agree Agree x 1
  3. Here, I'll help you out bro. Click here
     
  4. ok, but what If i have for instance 2 things that are 0.5 how would I do that?
     
  5. if you mean there are two things that have a 0.5% change just times the 0.5 by 10 to get 5 then generate a random number (0-1000)
    then see if its smaller than 5