Setting min-max number
#1

Hey, I'm sure ****** or someone made a little snippet where you could have a random number being created, but you could set a min/max part. Such as:
pawn Код:
new rand;
rand = random(60000);
//Then a min/max part
So basically what I'm saying is: Can't you do a random timer between something like: 1min and 1min 30 seconds?
Reply
#2

Its not hard, just do it like this:
new rnd = random((MAX_VALUE - MIN_VALUE)) + MIN_VALUE;

or use this define:

#define randommin(%1, %2) random(%1 - %2) + %2


untested
Reply
#3

Thanks =D
Reply
#4

This is probably what you have been originally looking for. Had it somewhere laying in an old script ..

pawn Код:
stock minrand(min, max) //By Alex "******" Cole
{
    return random(max - min) + min;
}
Reply
#5

Thanks for that too ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)