FuriouZ Posted December 20, 2013 Share Posted December 20, 2013 (edited) Hello, my userpanel have very weird thing... [EDIT]: Fixed and deleted code. Edited December 21, 2013 by Guest Link to comment
pa3ck Posted December 20, 2013 Share Posted December 20, 2013 month - months since January (0-11) year - years since 1900 ( so time.year + 1900 ) ( getRealTime) Also, you will need to use onClientRender or setTimer to update the time. Link to comment
DNL291 Posted December 21, 2013 Share Posted December 21, 2013 Use dxDrawText with onClientRender instead of guiCreateLabel. Link to comment
mcer Posted December 21, 2013 Share Posted December 21, 2013 Try this --Values GUIEditor = {} local timeB = getRealTime() local rRoot = resourceRoot local monthday = timeB.monthday local month = timeB.month local year = timeB.year function drawUserpanel() GUIEditor.sidebar = guiCreateStaticImage(0.84, 0.00, 0.16, 1.00, "img/sidebar.png", true) --Clock labels GUIEditor.clockHoursLabel = guiCreateLabel(0.00, 0.00, 0.797, 0.12, "Hours", true, GUIEditor.sidebar) GUIEditor.clockMinutesLabel = guiCreateLabel(0.00, 0.00, 1.197, 0.12, "Minutes", true, GUIEditor.sidebar) GUIEditor.dateLabel = guiCreateLabel(0.08, 0.09, 0.89, 0.03, ""..monthday.."."..month.."."..year.."", true, GUIEditor.sidebar) setTimer ( function() local timeC = getRealTime() local minutes = timeC.minute local hours = timeC.hour guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") end, 50, 0 ) end addEventHandler("onClientResourceStart", rRoot,drawUserpanel) Link to comment
xXMADEXx Posted December 21, 2013 Share Posted December 21, 2013 use this code, your time variables were global and never updated. --Values GUIEditor = {} local rRoot = resourceRoot local doRender = false function drawUserpanel() GUIEditor.sidebar = guiCreateStaticImage(0.84, 0.00, 0.16, 1.00, "img/sidebar.png", true) GUIEditor.clockHoursLabel = guiCreateLabel(0.00, 0.00, 0.797, 0.12, "Hours", true, GUIEditor.sidebar) GUIEditor.clockMinutesLabel = guiCreateLabel(0.00, 0.00, 1.197, 0.12, "Minutes", true, GUIEditor.sidebar) GUIEditor.dateLabel = guiCreateLabel(0.08, 0.09, 0.89, 0.03, "monthday.month.year", true, GUIEditor.sidebar) doRender = true addEventHandler ( "onClientRender", root, executeRender ) end addEventHandler("onClientResourceStart", rRoot,drawUserpanel) function executeRender ( ) if ( doRender ) then local time = getRealTime() local hours = time.hour local minutes = time.minute local monthday = time.monthday local month = time.month local year = time.year guiSetText ( GUIEditor.clockHoursLabel, hours..":" ) guiSetText ( GUIEditor.clockMinutesLabel, minutes..":" ) guiSetText ( GUIEditor.dateLabel, table.concat ( { monthday, month, year }, "." ) ) else removeEventHandler ( 'onClientRender', root, executeRender ) end end Link to comment
FuriouZ Posted December 21, 2013 Author Share Posted December 21, 2013 (edited) Thanks to you all I used mcer's code, thanks all works fine now,but month and year is still wrong [EDIT]: Fixed and deleted code. Edited December 21, 2013 by Guest Link to comment
pa3ck Posted December 21, 2013 Share Posted December 21, 2013 Oh, sorry, did not see this part: setTimer ( function() guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") end, 50, 0 ) You will need to get the 'new' time every time you execute the timer: setTimer ( function() local time = getRealTime() local minute = time.minute local hours = time.hour guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") end, 50, 0 ) (Just in case you still don't know where the problem was) Link to comment
./BlackBird# Posted December 21, 2013 Share Posted December 21, 2013 local month = time.month + 1 local year = time.year + 1900 Link to comment
FuriouZ Posted December 21, 2013 Author Share Posted December 21, 2013 Oh, sorry, did not see this part: setTimer ( function() guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") end, 50, 0 ) You will need to get the 'new' time every time you execute the timer: setTimer ( function() local time = getRealTime() local minute = time.minute local hours = time.hour guiSetText ( GUIEditor.clockHoursLabel, ""..hours..":") guiSetText ( GUIEditor.clockMinutesLabel, " "..minutes.."") end, 50, 0 ) (Just in case you still don't know where the problem was) God, clock works fine now, updates itself,but date is wrong sould be 21.12.2013 but it is 21.11.133 lol Link to comment
FuriouZ Posted December 21, 2013 Author Share Posted December 21, 2013 local month = time.month + 1 local year = time.year + 1900 Thanks AlcatRaz ! and all who helped me , all is fine now I still have one last question, how to do if the clock is 11:04 then it is 11:04 not 11:4 Link to comment
./BlackBird# Posted December 21, 2013 Share Posted December 21, 2013 string.format("%02d",minutes) Link to comment
FuriouZ Posted December 21, 2013 Author Share Posted December 21, 2013 string.format("%02d",minutes) Thanks !, works fine 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