tosfera Posted August 13, 2013 Share Posted August 13, 2013 just try this, is this what you want? addEventHandler( "onClientResourceStart", getRootElement(), function() addEventHandler("onClientPreRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientPreRender", getRootElement(), timestart) end,1000000,1) end) function timestart() guiSetText(label, "Time: "); label = guiCreateLabel(0.0, 0.95, 0.1, 0.1, "Time: ".. convertMS(math.ceil(getTimerDetails(timer) / 1000)), true); end function convertMS( timeMs ) local minutes = math.floor( timeMs / 60 ) local timeMs = timeMs - minutes * 60; local seconds = math.floor( timeMs / 60 ) local ms = timeMs - seconds * 60; return string.format( '%02d :%3d', minutes, ms ); end This is wrong. You are creating every frame a label... Use this: addEventHandler( "onClientResourceStart", getRootElement(), function() label = guiCreateLabel(0.0, 0.95, 0.1, 0.1, "Time: ", true); addEventHandler("onClientRender", getRootElement(), timestart) if isTimer(timer) then killTimer(timer) end timer = setTimer(function() removeEventHandler("onClientRender", getRootElement(), timestart) end,1000000,1) end) function timestart() guiSetText(label, "Time: " ..convertMS(math.ceil(getTimerDetails(timer) / 1000)) ) end function convertMS( timeMs ) local minutes = math.floor( timeMs / 60 ) local timeMs = timeMs - minutes * 60; local seconds = math.floor( timeMs / 60 ) local ms = timeMs - seconds * 60; return string.format( '%02d :%3d', minutes, ms ); end yes I was, and I did that because the onClientPreRender kept placing new characters into the screen and it became unable to read. 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