How to create randoms with exceptions
#5

Use an array, something like:
pawn Код:
new array = {0, 1, 2, 3, 4}, count = sizeof(array), selected[5];
selected[0] = random(count);
array[selected[0]] = array[-- count];
selected[1] = random(count);
array[selected[1]] = array[-- count];

and so on...
Note that this example is only for consecutive numbers, you'd have to write your own version if you'd like to use any value.
Reply


Messages In This Thread
How to create randoms with exceptions - by coool - 17.12.2016, 12:44
Re: How to create randoms with exceptions - by Dayrion - 17.12.2016, 12:54
Re: How to create randoms with exceptions - by NaS - 17.12.2016, 15:47
Re: How to create randoms with exceptions - by coool - 17.12.2016, 15:58
Re: How to create randoms with exceptions - by SickAttack - 17.12.2016, 16:07
Re: How to create randoms with exceptions - by NaS - 17.12.2016, 16:56

Forum Jump:


Users browsing this thread: 1 Guest(s)