VTX Posted February 24, 2014 Share 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. Link to comment
WhoAmI Posted February 24, 2014 Share Posted February 24, 2014 Just do one if if (minutes < 10) then minutes = "0"..minutes end Sam with hours. Link to comment
Sasu Posted February 24, 2014 Share 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) Link to comment
VTX Posted February 24, 2014 Author Share Posted February 24, 2014 It's working, thanks. 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