new random
#1

Helo!
If i have a code like that
PHP Code:
            new rand random(5);
            switch(
rand)
            {
                case 
0:
                {
                    new 
rand random(5);
                    {
                        and 
there others random
                    
}
                }
                case 
1:
                {
                    new 
rand random(5);
                    {
                        and 
there others random
                    
}
                }
                case 
2:
                {
                    new 
rand random(5);
                    {
                        and 
there others random
                    
}
                }
                case 
3:
                {
                    new 
rand random(5);
                    {
                        and 
there others random
                    
}
                }
                case 
4:
                {
                    new 
rand random(5);
                    {
                        and 
there others random
                    
}
                } 
I have how to optimize? Or to kill some random and still work?
Reply
#2

No need to initialize random values within each case. Also the brackets are useless there.

pawn Code:
new rand = random(5);
switch(rand)
{
    case 0:
    {

    }
    case 1:
    {

    }
    case 2:
    {

    }
    case 3:
    {

    }
    case 4:
    {

    }
}
Reply
#3

Quote:
Originally Posted by Skimmer
View Post
No need to initialize random values within each case. Also the brackets are useless there.

pawn Code:
new rand = random(5);
switch(rand)
{
    case 0:
    {

    }
    case 1:
    {

    }
    case 2:
    {

    }
    case 3:
    {

    }
    case 4:
    {

    }
}
you not understand, in each case i have a'n random man
Reply
#4

Code:
new rand = random(5);
{
and there others random
}
what are the point of having the brackets here? Does it even compile?
Anyway, if you're having a random number calculated everytime, why not do it once below the first random?
(i.e. having
Code:
new rand1 = random(5); 
new rand2 = random(5);
switch(rand1)
...
)
The code would be cleaner. Besides that, nothing to improve really.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)