Jump to content

help countdown help please !!!! ##


☠ RaZeR ☠

Recommended Posts

i want to reset the countdown by button

# and the " if " in line 12 | didnt work >> check if the window visble then start contdown !!

the countdown start after the resource start

    local countdownMS = getTickCount() + 350000 
  
function getTimeMS(ms) 
    local minutes = math.floor(ms/60000) 
    ms = ms - minutes * 60000 
    local seconds = math.floor(ms/1000) 
    return minutes,seconds 
end 
  
----------- 
setTimer (function() 
if ( guiGetVisible ( idlewind ) == true ) then 
        local m,s = getTimeMS(countdownMS-getTickCount()) 
        guiSetText( timer, " Minutes: "..m.." |  Seconds:"..s ); 
            end 
    end, 1000, 0 ) 

Edited by Guest
Link to comment

I don't really understand what you want.

If you want the countdown to start after opening the GUI, why do you put countdownMS there and don't put the setTimer in the function, which opens the GUI?

If you want to reset the countdown just use

countdownMS = getTickCount() + 350000

again

Link to comment
I don't really understand what you want.

If you want the countdown to start after opening the GUI, why do you put countdownMS there and don't put the setTimer in the function, which opens the GUI?

If you want to reset the countdown just use

countdownMS = getTickCount() + 350000

again

setTimer (function() 
if ( guiGetVisible ( idlewind ) == true ) then 
    local countdownMS = getTickCount() + 350000       <<<<<<<<<<<<<<< 
        local m,s = getTimeMS(countdownMS-getTickCount()) 
        guiSetText( timer, " Minutes: "..m.." |  Seconds:"..s ); 
            end 
            end 
    end, 1000, 0 ) 

Link to comment
local countdownMS = false 
  
setTimer ( function() 
    if guiGetVisible ( idlewind )  then 
        if not countdownMS then 
            countdownMS = getTickCount() + 350000 
        end 
        local m,s = getTimeMS(countdownMS-getTickCount()) 
        guiSetText( timer, " Minutes: "..m.." |  Seconds:"..s ); 
    else 
        countdownMS = false    -- if you wanna stop the countdown when gui is closed. 
    end 
end, 1000, 0 ) 

And just use

countdownMS = getTickCount() + 350000

again to reset the Countdown.

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