Eistee Posted August 22, 2014 Posted August 22, 2014 function () outputChatBox ("bla bla", source, 255, 0, 0, false) killTimer (timer1) end function (player) timer1 = setTimer ( function() outputChatBox ("miau miau", source, 255, 0, 0, false) end, 5000, 1 ) end I like to kill the timer "timer1" before it starts. So, before 5 seconds pass, the timer 1 should be killed. Error: WARNING: points\core_s.lua:150: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got nil]
Anubhav Posted August 22, 2014 Posted August 22, 2014 [lua] function hi() outputChatBox ("bla bla", source, 255, 0, 0, false) if isTimer(timer1) then killTimer (timer1) end end function (player) timer1 = setTimer ( function() outputChatBox ("miau miau", source, 255, 0, 0, false) end, 5000, 1 ) end hi() [lua]
Karoffe Posted August 22, 2014 Posted August 22, 2014 local timer1 function () outputChatBox ("bla bla", source, 255, 0, 0, false) if isTimer(timer1) then killTimer (timer1) end end function (player) timer1 = setTimer ( function() outputChatBox ("miau miau", source, 255, 0, 0, false) end, 5000, 1 ) end
Mr_Moose Posted August 22, 2014 Posted August 22, 2014 You can't kill a timer before it's created, secondly the third argument (1) in the creation of your timer will kill it automatically. If you want to kill it before as some kind of interrupt you need to make a command handler for your first function and give it a name, as it is now the kill function will be executed as soon you start the resource.
Eistee Posted August 22, 2014 Author Posted August 22, 2014 Oh ye thank you How can i fix this? : setTimer ( function() if isTimer(timer1) then killTimer ( timer1 ) elseif isTimer(timer2) then killTimer ( timer2 ) elseif isTimer(timer3) then killTimer ( timer3 ) elseif isTimer(timer4) then killTimer ( timer4 ) end, 1000, 1 ) end [2014-08-22 12:19:42] SCRIPT ERROR: points\core_s.lua:229: unexpected symbol near ',' [2014-08-22 12:19:42] ERROR: Loading script failed: points\core_s.lua:229: unexpected symbol near ','
Mr_Moose Posted August 22, 2014 Posted August 22, 2014 By ending the function you have within your timer of course. setTimer ( function() if isTimer(timer1) then killTimer ( timer1 ) elseif isTimer(timer2) then killTimer ( timer2 ) elseif isTimer(timer3) then killTimer ( timer3 ) elseif isTimer(timer4) then killTimer ( timer4 ) end end, 1000, 1 )
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