AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   four unequal random number (https://forums.alliedmods.net/showthread.php?t=240700)

c2d22 05-20-2014 12:27

four unequal random number
 
how to generate four unequal random number in a array. , Something with four loops will do it , maybe some other way exist , please tell me.

OnePL 05-20-2014 13:07

Re: four unequal random number
 
random[sizeof(array)] ?

c2d22 05-20-2014 13:09

Re: four unequal random number
 
:twisted:
i meant , i want to create 4 random num which are unequal to each other..

PHP Code:

new random[4]
random[0] =  random_num(0,10)
random[1] =  random_num(0,10)
random[2] =  random_num(0,10)
random[3] =  random_num(0,10)


// and i want all these number to be unequal , any way without looping? example please 


YamiKaitou 05-20-2014 13:11

Re: four unequal random number
 
The only way to make sure they are not the same is to use a loop

c2d22 05-20-2014 14:03

Re: four unequal random number
 
Quote:

Originally Posted by YamiKaitou (Post 2140368)
The only way to make sure they are not the same is to use a loop

Please give an example , i messed up something . i am unable to.

Black Rose 05-20-2014 17:41

Re: four unequal random number
 
What is the range of these random numbers?
If you keep it 1-31 or 0-30 you can use a bitsum instead of looping through all previous values.


All times are GMT -4. The time now is 09:38.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.