Raised This Month: $ Target: $400
 0% 

Map menu with fixed map in every map.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blue Snake.
Member
Join Date: May 2011
Location: Romania
Old 08-14-2011 , 12:25   Re: Map menu with fixed map in every map.
Reply With Quote #1

PHP Code:
public randoms(const start, const enddest[], const len)
{
    new 
numberbool:found=false
    
for(new i=0;i<len;i++)
    {
        while(!
found)
        {
            
found=false
            number
=random_num(startend)
            for(new 
j=0;j<i;j++)
                if(
number!=dest[j])
                {
                    
found=true
                    
break;
                }
            
dest[i]=number
        
}
    }

Not tested.

Last edited by Blue Snake.; 08-14-2011 at 12:27.
Blue Snake. is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 08-15-2011 , 14:33   Re: Map menu with fixed map in every map.
Reply With Quote #2

Quote:
Originally Posted by Blue Snake. View Post
PHP Code:
public randoms(const start, const enddest[], const len)
{
    new 
numberbool:found=false
    
for(new i=0;i<len;i++)
    {
        while(!
found)
        {
            
found=false
            number
=random_num(startend)
            for(new 
j=0;j<i;j++)
                if(
number!=dest[j])
                {
                    
found=true
                    
break;
                }
            
dest[i]=number
        
}
    }

Not tested.
I don't understand your code
Can you tell more detail about it and I update a little of my code in #1.
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-15-2011 , 14:42   Re: Map menu with fixed map in every map.
Reply With Quote #3

Quote:
Originally Posted by Blue Snake. View Post
PHP Code:
public randoms(const start, const enddest[], const len)
{
    new 
numberbool:found=false
    
for(new i=0;i<len;i++)
    {
        while(!
found)
        {
            
found=false
            number
=random_num(startend)
            for(new 
j=0;j<i;j++)
                if(
number!=dest[j])
                {
                    
found=true
                    
break;
                }
            
dest[i]=number
        
}
    }

Not tested.
That's a bad method.
See my tutorial about getting random values from an array.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 08-16-2011 , 08:09   Re: Map menu with fixed map in every map.
Reply With Quote #4

Quote:
Originally Posted by Exolent[jNr] View Post
That's a bad method.
See my tutorial about getting random values from an array.
I decided to give up
I had watch your tutorial's. It seems very difficult to me
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-16-2011 , 10:11   Re: Map menu with fixed map in every map.
Reply With Quote #5

Quote:
Originally Posted by GarbageBox View Post
I decided to give up
I had watch your tutorial's. It seems very difficult to me
Getting random values isn't difficult at all.

You basically want to set up all values you want in an array.
Then, as you select values, delete them from the array.

Code:
stock random_range(_min, _max, output[], size) {     new Array:values = ArrayCreate(1), numValues;     for(new i = _min; i <= _max; i++)     {         ArrayPushCell(values, i);         numValues++;     }         new rand, i;     while(i < size && numValues > 0)     {         rand = random(numValues);                 output[i++] = ArrayGetCell(values, rand);                 ArrayDeleteItem(values, rand);         numValues--;     }         ArrayDestroy(values);         return i; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-16-2011 , 15:13   Re: Map menu with fixed map in every map.
Reply With Quote #6

Quote:
Originally Posted by GarbageBox View Post
I decided to give up
I had watch your tutorial's. It seems very difficult to me
You don't have to understand how the function works at all. You just need to know how to give it the arguments.
__________________
fysiks is offline
Blue Snake.
Member
Join Date: May 2011
Location: Romania
Old 08-17-2011 , 18:07   Re: Map menu with fixed map in every map.
Reply With Quote #7

Exolent, so you create an array with consecutive numbers from min to max and then delete them?

It seems to be faster if len is high, but for 5 numbers, creating a big array isn't slower?
Blue Snake. is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-17-2011 , 18:32   Re: Map menu with fixed map in every map.
Reply With Quote #8

Quote:
Originally Posted by Blue Snake. View Post
Exolent, so you create an array with consecutive numbers from min to max and then delete them?

It seems to be faster if len is high, but for 5 numbers, creating a big array isn't slower?
With mine, there is no possibility for extra (and possibly infinite) loops.

Also, those aren't "big" arrays at all.
They are the size of what you put into them.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 03:23.


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