Jump to content

[HELP] Time isn't resetting


LabiVila

Recommended Posts

addEvent ("startCount", true) 
addEventHandler ("startCount", getRootElement(), 
    function () 
        ableToStart = true 
        if (ableToStart == true) then 
            addEventHandler ("onClientRender", getRootElement(), drawYourtime) 
        end 
    end 
) 
  
function handlerOnStart () 
    ableToStart = false 
    if (ableToStart == false) then 
        removeEventHandler ("onClientRender", getRootElement(), drawYourtime) 
    end 
end 
addEvent ("onClientMapStarting", true) 
addEventHandler ("onClientMapStarting", getRootElement(), handlerOnStart) 
  
function drawYourtime () 
    if not ut then 
        ut = getTickCount () 
    end 
    aut = getTickCount () 
    yourTime = formatMilliseconds (aut - ut) 
     
    dxDrawText (yourTime, 1275, 35, x, y, tocolor (255, 255, 255, 200), 1, "default-bold") 
end 

I want 'yourTime' to reset everytime the map changes, but it's actually continuing where it left off, any help?

Link to comment

The way the drawYourTime checks for ut, it shouldn't work. It checks if ut is nil or not, if it is it sets ut to the current tick count. So, if ut is set to zero, it won't update its value.

if not ut or ut == 0 then 

This way it'll update it if it's equal to zero.

You could just update ut whenever the event is triggered and not worry about updating it in the drawYourTime function.

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