Raised This Month: $ Target: $400
 0% 

random_num .. not that random


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cv3
Junior Member
Join Date: Sep 2014
Old 12-27-2014 , 13:57   random_num .. not that random
Reply With Quote #1

Okay I pick up few rows from a text file and have to select 1 in random, I used

PHP Code:
random_num(0,TOTALROWS 1
the problem occurs, I have 5 servers selecting from the same file. And they are not supposed to "random" select the same thing. At all this random_num thing is not that random .. how can I randomize it completely ?
Cv3 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-27-2014 , 19:23   Re: random_num .. not that random
Reply With Quote #2

Quote:
Originally Posted by Cv3 View Post
PHP Code:
random_num(0,TOTALROWS 1
If you are using it to select a random index for an array, you should use random(sizeof(my_array)).


Quote:
Originally Posted by Cv3 View Post
the problem occurs, I have 5 servers selecting from the same file. And they are not supposed to "random" select the same thing.
What you describe here is NOT purely random.

Quote:
Originally Posted by Cv3 View Post
At all this random_num thing is not that random .. how can I randomize it completely ?
You just said that you didn't want a random selection because you don't want your other servers to get the same number. This is how random works. There is a chance that you will get the same number every single time that the function is used.

random() and random_num() is the most random you can get with AMX Mod X. Other computer-based random functions won't be much, if any, better than these. If you want truly random, start flipping coins (but you don't want random because you stated that in your post).

In conclusion, if you want help, you will need to describe better your situation and what you really want (not what you think you need to get what you want; aka "The XY Problem").

EDIT: This might be helpful: [HOW TO] Retrieve random values from an array without retreiving the same twice
__________________

Last edited by fysiks; 12-27-2014 at 19:32.
fysiks is offline
Cv3
Junior Member
Join Date: Sep 2014
Old 12-29-2014 , 21:05   Re: random_num .. not that random
Reply With Quote #3

I figured it out, the problem was actialy the timing. All the servers are launched using a bash script at the same time, after adding a delay in the loop it fixed itself. No need to modify the plugin *whew*

I think it couldn't be described better, the way that every 'randomizing' function works is by using some hardware timing and when I launch them all 5 at the same time it stucks like that.

Last edited by Cv3; 12-29-2014 at 21:11.
Cv3 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:17.


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