heroes9898 Posted May 31, 2014 Share Posted May 31, 2014 Is there any way to stop a timer? something like that? setTimer( function() if getPlayerMoney(client) >= 1200 then --do sth. else --[b][color=#FF0000]break[/color][/b] ? --[b][color=#FF0000]return[/color][/b] ? --[b][color=#FF0000]...[/color][/b] ? end end, 1000, [b][color=#FF0000]0[/color][/b] ) Link to comment
Mr_Moose Posted May 31, 2014 Share Posted May 31, 2014 setTimer returns a timer pointer which can be used to kill a timer with the function killTimer: local timer = setTimer( ... ) killTimer(timer) Link to comment
heroes9898 Posted May 31, 2014 Author Share Posted May 31, 2014 But I need to stop an undefined timer in its function. Link to comment
Mr_Moose Posted May 31, 2014 Share Posted May 31, 2014 Why not simply define it? That's how lua works basically: local globalTimer1 = setTimer( function() if getPlayerMoney(client) >= 1200 then -- Do somethnig here else -- Kill timer killTimer(globalTimer1) end end, 1000, 0) You may be able to use "break" as well, never tried it myself even thought that's how you kill a timer in other languages. 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