View previous topic :: View next topic |
Author |
Message |
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Jul 27, 2021 6:44 am Post subject: Destroy all timers |
|
|
Is there's lua command that allows to destroy all timers?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Tue Jul 27, 2021 7:11 am Post subject: |
|
|
No. It's your responsibility to keep track of them
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Tue Jul 27, 2021 7:13 am Post subject: |
|
|
In short, no. You have to manually destroy the timer objects, it's usually done in the logic of the function that determines whether the timer should continue or not.
Or you could use this function instead:
Code: |
createTimer(delay, function(...),...):
Creates a timer object that waits the given delay, executes the given function, and then self-destructs
|
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Tue Jul 27, 2021 8:44 am Post subject: |
|
|
Maybe a solution can be provided with an arrangement.
Some requirements:
1) The created Timer should follow each other's order (tim1-tim2-tim3 etc.)
2) While creating the Timer, an existing function must be ready and this assignment must be made during creation (tim3.OnTimer=yourTim3Function)
3) The render function and the function of the key that killed it should be at the bottom of the Script code.
Here is the code sample;
Code: | local allTimer={ }
local timerCrtNil=1
function TimerNil()
for i=0, 3 do
allT=allTimer["myT"..i+1]
if allT then
allT.Destroy() allT=nil end
end
end
--Must always be dead at the entrance
TimerNil()
--script code
--...
--...
function TimerCreate()
allTimer.myT2=createTimer() allTimer.myT2.Interval=1000 allTimer.myT2.Enabled=false
allTimer.myT2.OnTimer=myT2Tick
allTimer.myT3=createTimer() allTimer.myT3.Interval=2000 allTimer.myT3.Enabled=false
allTimer.myT3.OnTimer=myT3Tick
allTimer.myT1=createTimer() allTimer.myT1.Interval=1000 allTimer.myT1.Enabled=true
allTimer.myT1.OnTimer=myT1Tick
allTimer.myT4=createTimer() allTimer.myT4.Interval=2000 allTimer.myT4.Enabled=false
allTimer.myT4.OnTimer=myT4Tick
end
--button timer create or nil function
function timerOpsion()
if timerCrtNil==1 then
TimerCreate()
timerCrtNil=2
else
TimerNil()
timerCrtNil=1
end
end
--UDF1.CEButton1.OnClick=timerOpsion |
Here is a test example;
Code: | local allTimer={ }
function TimerNil()
for i=0, 3 do
allT=allTimer["myT"..i+1]
if allT then
allT.Destroy() allT=nil end
end
end
--Must always be dead at the entrance
TimerNil()
local aa=0
local timerCrtNil=1
function myT2Tick()
aa=tonumber(aa) + 1
print("myT2 Tick: "..aa)
if aa==10 then
allTimer.myT2.Enabled=false
end
end
function myT1Tick()
aa=tonumber(aa) + 1
print("myT1 Tick: "..aa)
if aa==10 then
TimerNil()
--check nil?
--allTimer.myT2.Enabled=true --result: "Error:Access violation"
--or create check
--allTimer.myT2=createTimer() allTimer.myT2.Interval=1000 allTimer.myT2.OnTimer=myT2Tick aa=0 allTimer.myT2.Enabled=true
end
end
--script code
--...
--...
function TimerCreate()
aa=0
allTimer.myT2=createTimer() allTimer.myT2.Interval=1000 allTimer.myT2.Enabled=false
allTimer.myT2.OnTimer=myT2Tick
allTimer.myT3=createTimer() allTimer.myT3.Interval=2000 allTimer.myT3.Enabled=false
allTimer.myT3.OnTimer=myT3Tick
allTimer.myT1=createTimer() allTimer.myT1.Interval=1000 allTimer.myT1.Enabled=true
allTimer.myT1.OnTimer=myT1Tick
allTimer.myT4=createTimer() allTimer.myT4.Interval=2000 allTimer.myT4.Enabled=false
allTimer.myT4.OnTimer=myT4Tick
end
--button timer create or nil function
function timerOpsion()
if timerCrtNil==1 then
TimerCreate()
timerCrtNil=2
else
TimerNil()
timerCrtNil=1
end
end
timerOpsion()
--UDF1.CEButton1.OnClick=timerOpsion
|
Enjoy it!
|
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Tue Jul 27, 2021 2:46 pm Post subject: |
|
|
Thanks for help!
|
|
Back to top |
|
|
|