Raised This Month: $ Target: $400
 0% 

Setting an unique value to each cell of an array.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
t3hNox
Senior Member
Join Date: Oct 2009
Old 11-25-2010 , 10:33   Setting an unique value to each cell of an array.
Reply With Quote #1

Hi. It is probably an easy thing to script but I have some problems with the code. See below:
PHP Code:
#include <amxmodx>

#define SIZE 10

new var[SIZE]
new 
iRandNum

public plugin_init()
{
    
register_plugin("Random Array Values""v0.1""t3h")
    
register_clcmd("say /print""cmdPrint")
}

public 
cmdPrint(id)
{
    for(new 
i=0SIZEi++)
    {
        
iRandNum random(SIZE)+1
        
        
for(new 0<= ij++)
        {
            if(var[
j] == iRandNum)
            {
                
//here I need to repeat the first loop so that there would be another random number
            
}
        }
        
        var[
i] = iRandNum
        client_print
(idprint_console"Number: %d", var[i])
    }


Last edited by t3hNox; 11-25-2010 at 10:38.
t3hNox 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 11:15.


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