I Want to create car selling mission but i dont know how to create random integer between a and b can someone help?
- Hero Member
- Creating own server!
- Posts: 513
« Reply #1, »
Hi, 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:Purely tested.
function Random(from, to) return (rand()*(to+1-from)) / (RAND_MAX+1)+from;
Hope you like it!
local n = Random(1000, 2000)
I am gamer, programmer and hacker. Try to find me!
« Reply #2, »