On your 1st post. You state that you need to random 10%,30%,60%.
Your 1st example:
on "function"
random(100) < 10 -> return 0
random(100) < 30 -> return 1
random(100) < 60 -> return 2
which will random(100) on each condition which will be something like:
55 < 10
20 < 30
80 < 60
which will already give the wrong random chance.
Your 2nd example:
on "function"
random(100) < 10 -> return 0
else random(100) < 30 -> return 1
else random(100) < 60 -> return 2
will follow the same thing. Except that it won't run through all 3 condition when the previous condition is met.
30 < 10 (false, go to else)
12 < 30 (true, skip the rest)
It will basically give the wrong random chance also.
Another example to explain clearer:
I create a variable rand to store the random once.
variable rand=0
rand = random(100)
Using the same variable, check through all 3 conditions.
eg. rand=30
if(rand >= 0 && rand < 10) // 10%
return 1
if(rand >= 10 && rand < 40) // 30%
return 2
if(rand >=40 && rand < 100) // 60%
return 3
Does this give a clearer view?