How to make a random number that won't go less than 10000 or higher than 40000?
#1

Ok the title basicly says all, Its been along time since I played around with randomizing numbers and can't rember how to do it.

For example in my script I have this code.

pawn Код:
RobberieInfo[MaxRobLimit] = 40000
RobberieInfo[MinRobLimit] = 10000
I was wondering how I can use them variables and make it pick a random number between them?
Reply
#2

pawn Код:
stock RandomEx(min, max) //******
{
    return random(max - min) + min;
}
pawn Код:
// Usage:
new random_number = RandomEx(RobberieInfo[MinRobLimit], RobberieInfo[MaxRobLimit]);
Reply
#3

EDIT: Late, nvm.
pawn Код:
stock random_between(min, max) { return (min + random(max - min));  }
Use this!
Reply
#4

Thanks guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)