Random number ..........
#1

I made a fish system so how can i know what numbers it can be from that code:
new randf = random(25)+15;

with this code when i do /fish it's usually gives me between 15-27


I want to make it betweeb 10-35
Reply
#2

Use this stock function.
pawn Код:
stock randomEx(min, max)
{    
    new rand = random(max-min)+min;    
    return rand;
}
Here is how you would use it in code.
pawn Код:
new randf = randomEx(10, 35);
Reply
#3

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Use this stock function.
pawn Код:
stock randomEx(min, max)
{    
    new rand = random(max-min)+min;    
    return rand;
}
Here is how you would use it in code.
pawn Код:
new randf = randomEx(10, 35);
No point in that memory allocation by the way (of "rand"), you could just shorten the whole function to this:

pawn Код:
stock randomEx(min, max) return random(max-min) + min;
A small change, but avoiding unnecessary memory allocation and redundant code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)