19.03.2016, 18:38
It's simple to understand with a little common sense.
random - Selects a random number, starting from 0. e.g. random(3), this would select a random number equal or between 0 and 2.
maximum_value - The returned value won't go over this value.
minimum_value - The returned value won't go below this value.
e.g.
RandomBetween(10, 20)
It would return a number equal or between 10 and 20.
minimum_value = 10 - maximum_value = 20
Now (random(maximum_value - minimum_value) + minimum_value) would do the following while respecting the parentheses:
(maximum_value - minimum_value)
20 - 10 = 10
random(10) - e.g. 5
5 + minimum_value
5 + 10 -> 15
pawn Код:
(random(maximum_value - minimum_value) + minimum_value)
maximum_value - The returned value won't go over this value.
minimum_value - The returned value won't go below this value.
e.g.
RandomBetween(10, 20)
It would return a number equal or between 10 and 20.
minimum_value = 10 - maximum_value = 20
Now (random(maximum_value - minimum_value) + minimum_value) would do the following while respecting the parentheses:
(maximum_value - minimum_value)
20 - 10 = 10
random(10) - e.g. 5
5 + minimum_value
5 + 10 -> 15