View previous topic :: View next topic |
Author |
Message |
etioplmld Advanced Cheater Reputation: 0
Joined: 09 Feb 2021 Posts: 74
|
Posted: Thu Sep 29, 2022 4:13 am Post subject: how to repeat a timer? |
|
|
make this function execute repeatedly,to get 5,4,3,2,1,0.end, 5,4,3,2,1,0.end......
This code can run.
Code: |
function countdownuse()
local jsct = 5
function countdown()
if jsct >= 0 then
print(jsct)
jsct = jsct - 1
else
print("end")
cdjs.destroy()
end
end
cdjs = createTimer()
cdjs.interval = 1000
cdjs.OnTimer = countdown
end
countdownuse()
|
but This is bug code
Code: |
function countdownuse()
local jsct = 5
function countdown()
if jsct >= 0 then
print(jsct)
jsct = jsct - 1
else
print("end")
cdjs.destroy()
end
end
cdjs = createTimer()
cdjs.interval = 1000
cdjs.OnTimer = countdown
end
for n = 0, 5 do
countdownuse()
end
|
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Thu Sep 29, 2022 6:46 am Post subject: |
|
|
instead of
Code: |
print("end")
cdjs.destroy()
|
do
and perhaps add another counter to make it stop after 6 times
_________________
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 |
|
|
etioplmld Advanced Cheater Reputation: 0
Joined: 09 Feb 2021 Posts: 74
|
Posted: Thu Sep 29, 2022 8:48 am Post subject: |
|
|
oh,good idea ,it is this.
Code: |
cdjs = createTimer()
local maincount = 3
local jsct = 5
function countdown()
if(jsct > 0 and maincount>0 )then
print(jsct)
jsct = jsct - 1
elseif (jsct == 0 and maincount>0) then
jsct = 5
maincount = maincount - 1
print("end")-- do some thing
else
print("realend") -- do some thing
cdjs.destroy()
end
end
cdjs.interval = 1000
cdjs.OnTimer = countdown
|
|
|
Back to top |
|
|
|