VTX Posted February 24, 2014 Posted February 24, 2014 Hey guys! I have this script: function time () local sWidth,sHeight = guiGetScreenSize() local hours = getRealTime().hour local minutes = getRealTime().minute dxDrawText(hours..":"..minutes,sWidth*0.95486, sHeight*0.01112, sWidth*0.00694, sHeight*0.01112,tocolor(160,160,160,255),0.6,"bankgothic","left","top",false,false,false) end addEventHandler ( "onClientRender", getRootElement(), time ) It works fine, except one thing: It doesn't put 0 before single numbers. For example, if it's '01:05' it shows '1:5'. I'm a beginner in scripting and I have no idea how to fix this, please help.
WhoAmI Posted February 24, 2014 Posted February 24, 2014 Just do one if if (minutes < 10) then minutes = "0"..minutes end Sam with hours.
Sasu Posted February 24, 2014 Posted February 24, 2014 Use string.format: dxDrawText(string.format("%02d:%02d", hours, minutes),sWidth*0.95486, sHeight*0.01112, sWidth*0.00694, sHeight*0.01112,tocolor(160,160,160,255),0.6,"bankgothic","left","top",false,false,false)
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