How to create random integer between 1000-2000

Started by Alpays, Jun 15, 2020, 07:56 AM

Previous topic - Next topic

Alpays

I Want to create car selling mission but i dont know how to create random integer between a and b can someone help?

umar4911

Quote from: EK.IceFlake on Feb 06, 2015, 05:16 AMHi, guys! After a bit of number-quenching and guesswork, I finally came up with my function that takes a random number from rand() and does some maths to make the from and to function work! It supports negative numbers, too. And also a mixture of negative and positive.
Here is the code:
function Random(from, to) return (rand()*(to+1-from)) / (RAND_MAX+1)+from;Purely tested.
Hope you like it!

local n = Random(1000, 2000)
I am gamer, programmer and hacker. Try to find me!
xD