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
t3hNox
Senior Member
Join Date: Oct 2009
Old 11-26-2010 , 16:08   Re: Setting an unique value to each cell of an array.
Reply With Quote #5

Sorry for double posting but I have another question related to this thread.
I want to make so that at the end there would be printed 8 numbers (defined with NUMSTOPRINT) in the client's console but none of them would be the one that holds AnotherRandVar value. Hope you understand what I mean.
PHP Code:
#include <amxmodx>

#define SIZE 10
#define NUMSTOPRINT 8

new var[SIZE]

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

public 
cmdPrint(id)
{
    new 
tmp[SIZE];
    for(new 
0SIZEi++)
    {
        
tmp[i] = 1;
    }
    new 
randtsize SIZE;
    for(new 
0SIZEi++)
    {
        
rand random(tsize);
        var[
i] = tmp[rand];
        
tmp[rand] = tmp[--tsize];
    }
    
    
//SEE FROM HERE:
    
new AnotherRandVar random(SIZE)+1
    
for(new i=0i<=NUMSTOPRINTi++)
    {
        if(var[
i] == AnotherRandVar)
        {
            
//don't print this value, print another one
        
}
        
client_print(idprint_console"Num: %d", var[i])
    }

So at the end there will be printed 8 different numbers and none of them is AnotherRandVar.
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