Jump to content

[HELP] Why not working killTimer?


Tokio

Recommended Posts

This is the code:

function stimers(thePlayer)
if getElementData(thePlayer,"asdasd") == true then
local lejartimer1 = setTimer(function() 
exports.fly_box:showBox (thePlayer,"info","10 mins!")
local lejartimer2 = setTimer(function()
exports.fly_box:showBox (thePlayer,"info","9 mins!")
end,60000, 1)
local lejartimer3 = setTimer(function()
exports.fly_box:showBox (thePlayer,"info","8 mins!")
end,120000, 1)
local lejartimer4 = setTimer(function()
exports.fly_box:showBox (thePlayer,"info","7 mins!")
end,180000, 1)
local lejartimer5 = setTimer(function()
exports.fly_box:showBox (thePlayer,"info","6 mins!")
end,240000, 1)
local lejartimer6 = setTimer(function()
exports.fly_box:showBox (thePlayer,"info","5 mins!")
end,300000, 1)
local lejartimer7 = setTimer(function()
exports.fly_box:showBox (thePlayer,"info","4 mins!")
end,360000, 1)
local lejartimer8 = setTimer(function()
exports.fly_box:showBox (thePlayer,"info","3 mins")
end,420000, 1)
local lejartimer9 = setTimer(function()
exports.fly_box:showBox (thePlayer,"info","2 mins")
end,480000, 1)
local lejartimer10 = setTimer(function()
exports.fly_box:showBox (thePlayer,"info","1 mins")
end,540000, 1)
local lejartimer11 = setTimer(function()
setElementVisibleTo(mark, thePlayer, false)
setElementData(thePlayer, "asdasd", false)
local pos = positions[math.random(1,#positions)]
setElementPosition ( mark, pos.x,pos.y,pos.z )
end,600000, 1)
end,100,1)
---
elseif getElementData(thePlayer,"asdasd") == false then
if isTimer ( lejartimer1 ) then killTimer ( lejartimer1 ) end
if isTimer ( lejartimer2 ) then killTimer ( lejartimer2 ) end
if isTimer ( lejartimer3 ) then killTimer ( lejartimer3 ) end
if isTimer ( lejartimer4 ) then killTimer ( lejartimer4 ) end
if isTimer ( lejartimer5 ) then killTimer ( lejartimer5 ) end
if isTimer ( lejartimer6 ) then killTimer ( lejartimer6 ) end
if isTimer ( lejartimer7 ) then killTimer ( lejartimer7 ) end
if isTimer ( lejartimer8 ) then killTimer ( lejartimer8 ) end
if isTimer ( lejartimer9 ) then killTimer ( lejartimer9 ) end
if isTimer ( lejartimer10 ) then killTimer ( lejartimer10 ) end
end
end
addEvent("ctimers",true)
addEventHandler("ctimers", root,stimers)

Why not working the killTimers? How to fix this?

Link to comment
13 minutes ago, quindo said:

The timers are defined in different scope and are local, so they aren't available where you want to destroy them. Delete the "local" from where you create timers, to move their declaration above the function. 

i deleted the local, but still not working the killTimer :S 

Link to comment

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