Raised This Month: $ Target: $400
 0% 

random_num with exceptions?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Silencer123
Veteran Member
Join Date: Jul 2006
Old 04-10-2007 , 09:26   random_num with exceptions?
Reply With Quote #1

I searched all over the forum and the documentation/wiki of AMXX,
but did not find anything that could answer this question. Nevertheless
for the case that this has been asked before, I am sorry.

My question is, if it is possible to make the random_num function handle
exceptions. For example, I want a random number between 0 and 1000.
Code:
random_num(0,1000)
Now I, for example, do not want to get the values 3, 55, 76, 102, 123, 666 and 998.
What would I do in order to have these exceptions? Note that these numbers
shall be able to vary and that I do not want to run the same function again and
again until an acceptable result has been generated. However, that would look
like this, but I do not think that it is good:
Code:
public random_0_1000(ex_a,ex_b,ex_c,ex_d,ex_e,ex_f,ex_g) {     new num=random_num(0,1000)     if(num!=ex_a&&num!=ex_b&&num!=ex_c&&num!=ex_d&&num!=ex_e&&num!=ex_f&&num!=ex_g)     {         return num     }     else     {         random_0_1000()     } }
If something like the following would work, I would be happy.
Code:
random_num(0,1000,!ex_a,!ex_b,!ex_c,!ex_d,!ex_e,!ex_f,!ex_g)
__________________
EAT YOUR VEGGIES

Last edited by Silencer123; 04-10-2007 at 09:30.
Silencer123 is offline
 



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 06:44.


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