LabiVila Posted August 31, 2015 Share Posted August 31, 2015 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
JR10 Posted August 31, 2015 Share Posted August 31, 2015 When is startCount triggered? Adding ut = nil in the startCount event handler could solve your problem, depending on when startCount is triggered. Link to comment
LabiVila Posted August 31, 2015 Author Share Posted August 31, 2015 Awesome, it's working startCount was triggered 'onRaceStateChanging (state == "running")', however, I tried settingut = 0 but it didn't work, shouldn't it? Link to comment
JR10 Posted August 31, 2015 Share Posted August 31, 2015 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
LabiVila Posted August 31, 2015 Author Share Posted August 31, 2015 Okay I totally get it, thank you so much Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now