LabiVila Posted August 31, 2015 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?
JR10 Posted August 31, 2015 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.
LabiVila Posted August 31, 2015 Author 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?
JR10 Posted August 31, 2015 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.
LabiVila Posted August 31, 2015 Author Posted August 31, 2015 Okay I totally get it, thank you so much
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