rusztamas Posted December 17, 2016 Share Posted December 17, 2016 Hello! I don't understand the setTimer wiki, can you please teach me how it works? I would do this if it would work: function hello() local timer = setTimer (60000) -- sets timer to a minute if timer == 0 then -- checks if timer is 0 outputChatBox ("0") -- outputs, that timer is null else return nil end end addEventHandler ("onClientResourceStart", getRootElement(), hello) This is a not working script, can you help me to make it work? Thank you! 1 Link to comment
Jusonex Posted December 17, 2016 Share Posted December 17, 2016 setTimer expects a callback function which is a function that is called once the timer has expired. function hello() local timer = setTimer( function() -- The function that is called when the timer expires outputChatBox ("0") -- outputs, that timer is null end, 6000, -- expire after 6000ms 1 -- execute only 1 time ) end addEventHandler ("onClientResourceStart", getRootElement(), hello) This example uses an anonymous function. You can however use a named function as well (i.e. just pass for example 'hello' instead of function() ... end) 3 Link to comment
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