Post: Randomize Function?
11-22-2015, 11:14 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Is there something i can use in gsc so that it picks a random number from like 1 - 10

so like this for example

    randomweapon()
{
pickrandom number from 1 - 10

if(get random number = 1)
{
level thread specialweapon1();
}
if(get random number = 2)
{
level thread specialweapon2();
}

all the way to 10
}


keep in mind this isnt actually for a random weapon.
it will be used to randomize out of which 10 level threads to pick.

would be appreciated Smile
(adsbygoogle = window.adsbygoogle || []).push({});
11-22-2015, 11:39 AM #2
Procyon
Gym leader
Check the randomize weapon script.
11-22-2015, 12:32 PM #3
-Numb
You talkin to me?
Originally posted by OfficialCoolJay View Post
Is there something i can use in gsc so that it picks a random number from like 1 - 10

so like this for example

    randomweapon()
{
pickrandom number from 1 - 10

if(get random number = 1)
{
level thread specialweapon1();
}
if(get random number = 2)
{
level thread specialweapon2();
}

all the way to 10
}


keep in mind this isnt actually for a random weapon.
it will be used to randomize out of which 10 level threads to pick.

would be appreciated Smile


Here you go Smile
    [B]RandomNumber = RandomIntRange(1,10);[/B]

RandomNumber (or what you call it) will be a random number from 1 to 10.
11-23-2015, 01:51 AM #4
Originally posted by Numb View Post
Here you go Smile
    [B]RandomNumber = RandomIntRange(1,10);[/B]

RandomNumber (or what you call it) will be a random number from 1 to 10.


would this work?

    RandomFunction()
{
RandomNumber = RandomIntRange(1,10);

if(RandomNumber <= 4)
{
iprintlnBold("Picked random number 4");
}
}
11-23-2015, 02:37 AM #5
got to work actually haha thanks Smile
11-27-2015, 04:20 AM #6
Im_YouViolateMe
NextGenUpdate Elite
Use a switch statement. It's more efficient.

    

test()
{
num = randomintrange(1,10); //remember it will only generate 1 through max - 1, so 1 - 9 in this case. it doesnt include the max number

switch(num)
{
case 1:
//code here
break;
case 2:
//code here
break;
}
}

//you have to add break before each new case or you will get an error
11-27-2015, 05:19 AM #7
Originally posted by YouViolateMe View Post
Use a switch statement. It's more efficient.

    

test()
{
num = randomintrange(1,10); //remember it will only generate 1 through max - 1, so 1 - 9 in this case. it doesnt include the max number

switch(num)
{
case 1:
//code here
break;
case 2:
//code here
break;
}
}

//you have to add break before each new case or you will get an error


oh that looks cleaner i will use, and i spent ages until i found out that i wasn't picking the highest number haha
thanks Smile

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo