Random problem.
#3

To get a random number from 1 to 5, use this:
pawn Код:
number = random(5) + 1;
The "random(5)" part returns any number from 0 to 4.
Then you simply add 1 to the result, then you get a random number from 1 to 5.

If you need 5 different random numbers, you could use an array to store them for later use:
pawn Код:
new RandomNumbers[5];

for (new i; i < 5; i++)
{
    RandomNumbers[i] = random(1000) + 1;
}
This code creates an array which can hold 5 integer values.
Each index (slot of the array) is filled with a random number between 1 and 1000.
Reply


Messages In This Thread
Random problem. - by ajwar - 15.02.2011, 11:48
Re: Random problem. - by [BEP]AcerPilot - 15.02.2011, 12:02
Re: Random problem. - by PowerPC603 - 15.02.2011, 17:06

Forum Jump:


Users browsing this thread: 1 Guest(s)