Mefisto_PL Posted December 23, 2011 Share Posted December 23, 2011 Hi, I have a problem with my script to show time. The script shows the time, but unfortunately that was the only time when the script has been included. For example, the script turned on 21:17 and this time shows me all the time. Please help me. local time = getRealTime() local hours = time.hour local minutes = time.minute addEventHandler("onClientPreRender", getRootElement(), function() local screenWidth, screenHeight = guiGetScreenSize() dxDrawText(hours..":"..minutes, screenWidth - 1160, 920, screenWidth - 110, 200, tocolor(0, 159, 255, 255), 1.5, "Arial", "center", "top", false, false, false) end ) Link to comment
TAPL Posted December 23, 2011 Share Posted December 23, 2011 addEventHandler("onClientRender", root, function() local screenWidth, screenHeight = guiGetScreenSize() local time = getRealTime() dxDrawText(time.hour..":"..time.minute, screenWidth - 1160, 920, screenWidth - 110, 200, tocolor(0, 159, 255, 255), 1.5, "Arial", "center", "top", false, false, false) end ) Link to comment
Xeno Posted December 23, 2011 Share Posted December 23, 2011 try just using onClientRender TAPL beat me to it , once again ;3 Link to comment
Mefisto_PL Posted December 23, 2011 Author Share Posted December 23, 2011 It works, but if we can do something to the equal time / for the first ten minutes, showed a 01 and so on? For example: 22:10 Link to comment
Aibo Posted December 23, 2011 Share Posted December 23, 2011 local screenWidth, screenHeight = guiGetScreenSize() addEventHandler("onClientRender", root, function() local time = getRealTime() dxDrawText(string.format("%02d:%02d", time.hour, time.minute), screenWidth - 1160, 920, screenWidth - 110, 200, tocolor(0, 159, 255, 255), 1.5, "Arial", "center", "top", false, false, false) end ) also you should really fix your positioning (screenWidth - 1160 is not the way, people with 1024 or 800 screen width wont see anything). if you want it to be on the left side, use positive pixel offset from the left side, which is 0. same with height. 920 pixels is way too far, for example i run mta at 1280x720, i wont see that. people with 1024x768 resolution also wont see that. and you'll be amazed how many people play at 800x600. Link to comment
Mefisto_PL Posted December 25, 2011 Author Share Posted December 25, 2011 (edited) Okey, but my friend play on 800 x 600 and he can't see this text . Can you help me fix this problem? ///EDIT I have this code and if anybody can fix this script, to show this panel everybody even those who has a resolution of 800 x 600 etc etc. Secret Edited December 25, 2011 by Guest Link to comment
TAPL Posted December 25, 2011 Share Posted December 25, 2011 read this Using guiGetScreenSize to fit GUI & DX drawing in all resolutions https://wiki.multitheftauto.com/wiki/GuiGetScreenSize 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