Jade Posted February 28, 2014 Posted February 28, 2014 addEventHandler("onClientRender",root, function() local hours = getRealTime().hour local minutes = getRealTime().minute local seconds = getRealTime().second dxDrawText(hours..":"..minutes..":"..seconds,0,0,10,10,tocolor(255,157,0,255),0.6,"bankgothic") end ) own script https://community.multitheftauto.com/in ... ls&id=5724 I need to guisettext -- author Reflex addEventHandler("onClientRender",root, function() local hours = getRealTime().hour local minutes = getRealTime().minute -- dxDrawText(hours..":"..minutes,x/1.093,y/10.8,74,10,tocolor(127, 199, 255,150),0.55,"bankgothic") end ) -- zamanayari = guiCreateLabel ( 0.01, 0.22, 0.3, 0.4, "Zaman",true ) function serverzamani() guiSetText(zamanayari, "?" ) end setTimer(serverzamani, 60000, 0)
WhoAmI Posted February 28, 2014 Posted February 28, 2014 zamanayari = guiCreateLabel ( 0.01, 0.22, 0.3, 0.4, "Zaman",true ) function serverzamani() local time = getRealTime() local hours = time.hour local minutes = timer.minute guiSetText(zamanayari, string.format("%02d:%02d", hours, minutes) ) end setTimer(serverzamani, 60000, 0)
iPrestege Posted February 28, 2014 Posted February 28, 2014 If you used 'onClientRender' It would be better .
Jade Posted February 28, 2014 Author Posted February 28, 2014 didn't work C.lua:6: attempt to index global 'timer' (a nil value)
WhoAmI Posted February 28, 2014 Posted February 28, 2014 Well, yea, my bad. zamanayari = guiCreateLabel ( 0.01, 0.22, 0.3, 0.4, "Zaman",true ) function serverzamani() local time = getRealTime() local hours = time.hour local minutes = time.minute guiSetText(zamanayari, string.format("%02d:%02d", hours, minutes) ) end addEventHadnler("onClientRender", root, serverzamani)
Jade Posted February 28, 2014 Author Posted February 28, 2014 addEventHadnler("onClientRender", root, serverzamani) I've changed addEventHandler worked thanks WhoAmI
Moderators Citizen Posted February 28, 2014 Moderators Posted February 28, 2014 Please use a setTimer instead ! CVC said it would be better but he is wrong because you are actually updating the text 30 times per second at 30FPS ! (and 60 for 60FPS etc) You can use a setTimer to update it every 5 seconds for example (not 60 (= 1min) because the timers aren't really accurate so by setting it at 5 seconds, the clock can be late from 5 secs at most which is totally acceptable for a clock the player won't really care about). By doing that you are reducing the client CPU load because your script will be executed 1 times every 5 seconds instead of 150 times at 30 FPS (and 300 at 60FPS). Hope it will help to understand what onClientRender is really used for.
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