Bean666 Posted July 6, 2016 Posted July 6, 2016 hello is it possible to add math.random for timers like these? i tested this one but it seems not to work: any tips? timer = setTimer(function() --stuff here-- end end, math.random(1000,5000), 0) Aftermath
Captain Cody Posted July 6, 2016 Posted July 6, 2016 time = math.random(1000,5000) timer = setTimer(function() --stuff here-- end end, time, 0)
Bonsai Posted July 6, 2016 Posted July 6, 2016 time = math.random(1000,5000) timer = setTimer(function() --stuff here-- end end, time, 0) How is that different? Isn't there just one "end" too much?
Bean666 Posted July 6, 2016 Author Posted July 6, 2016 can't there be a time table math.random is not so accurate on what i'm doing ,is it the only way? like ex: local time = { 1000, 3000 } or whatever. Aftermath
Captain Cody Posted July 6, 2016 Posted July 6, 2016 local time = {1,2,3,4,45,56333,3} local random = math.random(0,#time) timer = setTimer(function() --stuff here-- end, time[random], 0) And yes, I didn't notice that extra end.
Bean666 Posted July 6, 2016 Author Posted July 6, 2016 already did that before i keep getting an error bad usage. timer interval is below 50 Aftermath
Captain Cody Posted July 6, 2016 Posted July 6, 2016 local time = {56333,3292,2123} ---<<-- Make sure to have numbers above 50 local random = math.random(0,#time) timer = setTimer(function() --stuff here-- end, time[random], 0) Oh yeh sorry forgot, make sure that the numbers are all above 50. If you wanted to use math.random to make the number -> local number = math.random(50,5000) -- Chooses a number in-between 50 and 5000
DarkByte Posted July 7, 2016 Posted July 7, 2016 local timerfrom, timerto = 5,30 --Time in minutes function setRandomTimer ( ) startTimer = setTimer( function ( ) end , math.random ( timerfrom, timerto ) * 60 * 1000 , 1 ) end addEventHandler ("onResourceStart", resourceRoot, function ( ) setRandomTimer ( ) end ) When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now