Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
random function ?!? - SOLVED
#1
How can i generate a random number betwen x and y ?

PS: how can i generate the same as integer?
Sorry for bad English Blush -> *GERMAN*
Reply

#2
So much noobs.....

http://zeroy.com/script/math/randomint.htm
Reply

#3
number = randomIntRange( min, max );
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#4
(11-03-2011, 16:35)jariz Wrote: So much noobs.....

http://zeroy.com/script/math/randomint.htm

How shoud i know this Wink
I didnt have found something, about making random funktion in gsc...
Sorry for bad English Blush -> *GERMAN*
Reply

#5
LOL, 2 users answered your post and you're still asking the same thing?
Reply

#6
(11-04-2011, 10:44)jariz Wrote: LOL, 2 users answered your post and you're still asking the same thing?

No, he's not. Read carefully.
Reply

#7
Code:
returnRandom( arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 )
{
    random = [];
    if( isDefined( arg1 ) ) random[0] = arg1;
    if( isDefined( arg2 ) ) random[1] = arg2
    if( isDefined( arg3 ) ) random[2] = arg3;
    if( isDefined( arg4 ) ) random[3] = arg4;
    if( isDefined( arg5 ) ) random[4] = arg5;
    if( isDefined( arg6 ) ) random[5] = arg6;
    if( isDefined( arg7 ) ) random[6] = arg7
    if( isDefined( arg8 ) ) random[7] = arg8;
    if( isDefined( arg9 ) ) random[8] = arg9;
    if( isDefined( arg10 ) ) random[9] = arg10;
    return random[ randomInt( random.size ) ];
}

use this:
random = returnRandom( "bla", "blabla", "blablabla", "hoi", "boe", "lala", "noob" );


or do you want this:
Code:
randomfunction()
{
    number = randomInt( 9 ); // 0 counts as a number so this would give 10 posibilities
    
    switch( number )
    {
        case 0:
        {
            //DO SHIT WHEN NUMBER = 0
            break;
        }
        case 1:
        {
            //DO SHIT WHEN NUMBER = 1
            break;
        }
        case 2:
        {
            //DO SHIT WHEN NUMBER = 2
            break;
        }
        case 3:
        {
            //DO SHIT WHEN NUMBER = 3
            break;
        }
        case 4:
        {
            //DO SHIT WHEN NUMBER = 4
            break;
        }
        case 5:
        {
            //DO SHIT WHEN NUMBER = 5
            break;
        }
        case 6:
        {
            //DO SHIT WHEN NUMBER = 6
            break;
        }
        case 7:
        {
            //DO SHIT WHEN NUMBER = 7
            break;
        }
        case 8:
        {
            //DO SHIT WHEN NUMBER = 8
            break;
        }
        case 9:
        {
            //DO SHIT WHEN NUMBER = 9
            break;
        }
    }
}
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#8
randomFloat(x, y)
it will generate random number between x and y
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#9
(11-04-2011, 14:22)Se7en Wrote: randomFloat(x, y)
it will generate random number between x and y

Float = 1.234321,3.141592,4.55....
Int = 1,2,3,6,1337,6000.....
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Release] [SOURCE] Random Weapons. [HARD] Tony. 1 4,092 11-08-2013, 11:11
Last Post: Nekochan
  Help source random weapons [HARD] Tony. 4 4,685 11-08-2013, 05:25
Last Post: [HARD] Tony.
  Help Help Function Fire dargula 1 2,147 10-31-2013, 23:03
Last Post: Nekochan
  Help choose 2 random players?(1 each team) 26hz 6 4,627 09-12-2013, 17:32
Last Post: Yamato
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 33,121 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks
  Help [C#] WebClient how to know real url [solved] narkos 21 12,887 09-09-2013, 15:21
Last Post: surtek
Information Help How to edit new derived entry? (Solved) SSonic70 1 2,710 08-20-2013, 15:29
Last Post: Nekochan
Exclamation [Request] Random Weapon At Spawn Scripts18 3 4,716 07-27-2013, 23:53
Last Post: DidUknowiPwn
  Help Receiving a random primary & secondary DidUknowiPwn 5 4,384 07-22-2013, 09:47
Last Post: Yamato
  What script controls the "random" aspect to care packages? akillj 2 3,254 06-05-2013, 11:24
Last Post: akillj

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.