Raised This Month: $51 Target: $400
 12% 

Module: RandomX


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 08-13-2005 , 17:35   Module: RandomX
Reply With Quote #1

Time again for yet another useless module by Twilight Suzuka....

Ever needed a random number generator that actually SEEMED random?
Ever needed to generate random strings, arrays, vectors, etc?
Ever really wanted a secure random salt generator for say, your MD5 or sockets plugin?

RandomX provides such functionality, and will soon provide even more.

RandomX uses a random number generator called the "Mersenne Twister", which is one of the fastest random number generators availible, and is light years ahead of the current ones implimented in AMXx. This means high quality and inexpensive randomized variables.

And, supposing anyone who codes for AMXx actually USES the sockets or MD5 functions, it has a higher cost, but more random, salt generator, useful for any hash or socket.

In addition, for anyone who wants a more randomized integer, float, or vector, the "iten" parameter will add another degree of randomness, at the cost of CPU. The higher the iten value, the more cycles the generator goes through to make your number, and thus the more random it is.

Functions:
Code:
// Generates a bool value native Bool:generate_bool(); // Generates an integer between lower and upper, cycles iten times. native generate_int(lower = 0,upper = CELL_MAX,iten = 1) // Generates a float between lower and upper, cycles iten times. native Float:generate_float(Float:lower = 0.0,Float:upper = FLOAT_MAX ,iten = 1) // Generates a vector between lower and upper, cycles iten times. native generate_vector(Float:vec[3],Float:lower = 0.0,Float:upper = FLOAT_MAX,iten = 1); // Generates a randomized string, not garanteed to fill the entire len. native generate_string(output[],len) // Generates an alpha numberical string, garanteed to fill the entire len native generate_alpha_string(output[],len) // Generates a highly random salt. native generate_salt(salt_value[], len = 34) // Generates a randomized value for each index of given array. native generate_array(output[],len)

Natives to be done:

Code:
// Returns the index of a new random number generator. Default seed is randomized based on global random number generator. native new_generator(seed[]= {0,...}) // Records state of given generator, so you can recreate it later native record_generator(gen_id,str[],len) // Loads state into a new generator. native load_generator(str[],len) // Seeds a generator with new values // seed_generator(gen_id,seed[] = {0,...}) All current natives will have another parameter added on the end for usage with custom generators.

Completely useless, unless you are doing something that needs it. For instance, creating extremely high quality fog requires this, or creating a motion picture inside of HL1 using special effects would require such a random number generator.

MTRand class highly altered by me, and Generator class created and maintained by me, for exclusive use with AMXx (not really needed anywhere else)

This could be very easily inserted into AMXx and used for many of its functions, but it probably won't be, as its not a terribly needed feature.
Attached Files
File Type: rar randomx.rar (66.9 KB, 791 views)
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
johnjg75
Veteran Member
Join Date: Mar 2004
Location: Delaware
Old 08-14-2005 , 07:01  
Reply With Quote #2

looks nice
__________________
johnjg75 is offline
Send a message via AIM to johnjg75 Send a message via MSN to johnjg75 Send a message via Yahoo to johnjg75
VanillA Ice
Senior Member
Join Date: Apr 2005
Old 08-16-2005 , 20:55  
Reply With Quote #3

hey nice module, as always ;)
__________________
I can no longer help here......school has started... :/ goodbye everybody :'(
VanillA Ice is offline
Send a message via MSN to VanillA Ice Send a message via Yahoo to VanillA Ice
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-24-2005 , 00:01  
Reply With Quote #4

If it's so useless then why did you sticky it? You know you don't have to sticky every module you make.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-24-2005 , 00:45  
Reply With Quote #5

modules with provided source will get stickied because its easier to find them instead of going through this forum. Unless otherwise asked by the author.
Freecode is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 08-24-2005 , 03:22  
Reply With Quote #6

And cause its awsome, even if useless. And I found it useful, damn it!
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-07-2005 , 17:58  
Reply With Quote #7

Hello, I've been trying to get a plugin working with this, but it seems slightly bugged. For some reason it won't detect the module, even though it's loaded. I'd also like to point out that you should compile the module on Linux, for Linux server owners.

Here is my "amxx plugins":

Code:
] amxx plugins
Currently loaded plugins:
       name               version  author            file             status   
 [  1] Admin Base         1.50     AMXX Dev Team     admin.amxx       running  
 [  2] Admin Commands     1.50     AMXX Dev Team     admincmd.amxx    running  
 [  3] Admin Help         1.50     AMXX Dev Team     adminhelp.amxx   running  
 [  4] Slots Reservation  0.9.7    f117bomb          slots_reservati  running  
 [  5] Menus Front-End    1.50     AMXX Dev Team     menufront.amxx   running  
 [  6] Commands Menu      1.50     AMXX Dev Team     cmdmenu.amxx     running  
 [  7] Players Menu       1.50     AMXX Dev Team     plmenu.amxx      running  
 [  8] Teleport Menu      1.50     AMXX Dev Team     telemenu.amxx    running  
 [  9] Maps Menu          1.50     AMXX Dev Team     mapsmenu.amxx    running  
 [ 10] Admin Chat         1.50     AMXX Dev Team     adminchat.amxx   running  
 [ 11] Anti Flood         1.50     AMXX Dev Team     antiflood.amxx   running  
 [ 12] Scrolling Message  1.50     AMXX Dev Team     scrollmsg.amxx   running  
 [ 13] Info. Messages     1.50     AMXX Dev Team     imessage.amxx    running  
 [ 14] Admin Votes        1.50     AMXX Dev Team     adminvote.amxx   running  
 [ 15] TimeLeft           1.50     AMXX Dev Team     timeleft.amxx    running  
 [ 16] Pause Plugins      1.50     AMXX Dev Team     pausecfg.amxx    running  
 [ 17] Stats Configurati  1.50     AMXX Dev Team     statscfg.amxx    running  
 [ 18] Restrict Weapons   1.50     AMXX Dev Team     restmenu.amxx    running  
 [ 19] StatsX             1.50     AMXX Dev Team     statsx.amxx      running  
 [ 20] CS Misc. Stats     1.50     AMXX Dev Team     miscstats.amxx   running  
 [ 21] CS Stats Logging   1.50     AMXX Dev Team     stats_logging.a  running  
 [ 22] unknown            unknown  unknown           amxx_random.amx  bad load 
Load fails: Module "RandomX" required for plugin.  Check modules.i
Here is my "amxx modules":
Code:
] amxx modules
Currently loaded modules:
      name                    version  author               status     
 [ 1] Fun                     1.50     AMX Mod X Dev Team   running    
 [ 2] Engine                  1.50     AMX Mod X Dev Team   running    
 [ 3] FakeMeta                1.50     AMX Mod X Dev Team   running    
 [ 4] MySQL                   1.50     AMX Mod X Dev Team   running    
 [ 5] GeoIP                   1.50     AMX Mod X Dev Team   running    
 [ 6] CStrike                 1.50     AMX Mod X Dev Team   running    
 [ 7] CSX                     1.50     AMX Mod X Dev Team   running    
 [ 8] War3ft                  2.2.5    Geesu (Pimp Daddy)   running    
 [ 9] RegEx                   1.50     AMX Mod X Dev Team   running    
 [10] RandomX                 1.17     Rukia                running    
10 modules
Here is the code for the plugin:

Code:
#include <amxmodx> #include <amxmisc> #include <randomx> public plugin_init() {     register_plugin("AMXX Random Numbers","1.0","Hawk552")     register_clcmd("amx_flipcoin","flipcoin",0," - flips a coin")     register_clcmd("say /flipcoin","pubflipcoin")     register_clcmd("amx_randomnum","randomnum",0," <min> <max> - generates a random number") } public pubflipcoin(id) {     new bool:heads_tails = bool:generate_bool()         if(heads_tails == true)     {         client_print(0,print_chat,"[AMXX] The coin flipped HEADS.")     }     else     {         client_print(0,print_chat,"[AMXX] The coin flipped TAILS.")     }     return PLUGIN_CONTINUE } public flipcoin(id) {     new bool:heads_tails = bool:generate_bool()         if(heads_tails == true)     {         client_print(id,print_console,"[AMXX] The coin flipped HEADS.")     }     else     {         client_print(id,print_console,"[AMXX] The coin flipped TAILS.")     }     return PLUGIN_CONTINUE } public randomnum(id,level,cid) {     if(!cmd_access(id,level,cid,3))     {         return PLUGIN_HANDLED     }         new min[32]     read_argv(1,min,31)         new max[32]     read_argv(1,max,31)         new num = generate_int(str_to_num(min),str_to_num(max))         client_print(id,print_chat,"[AMXX] The number is %s.",num)         return PLUGIN_HANDLED }

Thanks.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
BAILOPAN
Join Date: Jan 2004
Old 09-07-2005 , 18:09  
Reply With Quote #8

I don't think for flipping coins you need an extra module ;] the standard-C library function should work (random_num).
__________________
egg
BAILOPAN is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-07-2005 , 18:52  
Reply With Quote #9

Code:
register_clcmd("amx_randomnum","randomnum",0," <min> <max> - generates a random number")
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
wiggles
Member
Join Date: Aug 2005
Old 09-08-2005 , 00:23  
Reply With Quote #10

nice coding
wiggles is offline
Reply



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 09:15.


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