Author Topic: Random Integer Generator  (Read 1868 times)

Samsanit

  • Guest
Random Integer Generator
« on: April 26, 2012, 04:30:05 pm »
I am working to make a random integer generator. It needs to have integers 0-295 as well as a script to limit a scrip to a 1/30 chance of working. I am using the command Rand. Does that help. Please I really need help on this

budershank

  • Guest
Re: Random Integer Generator
« Reply #1 on: April 26, 2012, 04:52:20 pm »
Really you just need two random commands and an if statement. 

Code: [Select]

 int iMyRandomNumberOfJoy;
if (Random(30) == 0)
{
      iMyRandomNumberOfJoy = Random(296);
}
else
{
     //No random number for you!
}

printf("%d", iMyRandomNumberOfJoy);



Barring any typos on that should work.  You could also add Randomize();  in front of everything to make your random numbers more random.

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Tim Sommers
DragonFireSDK Team

Samsanit

  • Guest
Re: Random Integer Generator
« Reply #3 on: April 26, 2012, 06:07:40 pm »
Thanks for the Help.