Jump to content

timer math.random?


Bean666

Recommended Posts

Posted

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

Posted
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?

Posted

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

Posted
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.

Wolf Inc Discord

Youtube channel
Github

Posted
    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

Wolf Inc Discord

Youtube channel
Github

Posted
  
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.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...