FSXTim Posted September 20, 2012 Share Posted September 20, 2012 Hallo, I want to kill the timer in this script. But now all the timers of the resource are killed. How can I only kill this one? function spam(message, messageType) local player = source local msg = getElementData(source, "Spam") if message == msg then outputChatBox("Bitte wiederhole dich nicht!", source, 255, 0, 0) cancelEvent() end timers = getTimers(10000) for timerKey, timerValue in ipairs(timers) do killTimer(timerValue) end setTimer( function() setElementData(player, "Spam", "0") end , 10000, 1) setElementData(source, "Spam", message) end addEventHandler("onPlayerChat", getRootElement(), spam) Greets Link to comment
DiSaMe Posted September 20, 2012 Share Posted September 20, 2012 Maybe not by looping through all timers, but by storing the value returned by setTimer into a variable and later using it in killTimer? Link to comment
FSXTim Posted September 20, 2012 Author Share Posted September 20, 2012 Sorry, but what do you exactly mean? Could you give me an example, please? Greets Link to comment
DiSaMe Posted September 20, 2012 Share Posted September 20, 2012 some_timer = setTimer(someFunction, 10000, 1) And later: killTimer(some_timer) Link to comment
TAPL Posted September 20, 2012 Share Posted September 20, 2012 some_timer = setTimer(someFunction, 10000, 1) And later: killTimer(some_timer) Use isTimer better. if isTimer(some_timer) then killTimer(some_timer) end Link to comment
FSXTim Posted September 20, 2012 Author Share Posted September 20, 2012 Thanks, it's working now. Greets 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