boro Posted May 20, 2013 Share Posted May 20, 2013 Please help how to setWeather ( 9 ) when is game time 20:00 ? Exist event for check game timer ? Link to comment
iPrestege Posted May 20, 2013 Share Posted May 20, 2013 (edited) Does it work fine? Edited May 20, 2013 by Guest Link to comment
boro Posted May 20, 2013 Author Share Posted May 20, 2013 is it good ? i dont must test it because am in school root = getRootElement () function checkTime () setTimer ( UpgradeWeather, 1000, 0 ) end addEventHandler ( "onClientRender", root, checkTime ) function UpgradeWeather ( ) local h, m = getTime() if h > 20 then setWeather ( 9 ) elseif h < 6 then setWeather ( 11 ) end end Link to comment
iPrestege Posted May 20, 2013 Share Posted May 20, 2013 addEventHandler("onClientRender",root, function ( ) local h, m = getTime() if h > 20 then setWeather ( 9 ) elseif h < 6 then setWeather ( 11 ) end end ) More easy . Link to comment
PaiN^ Posted May 20, 2013 Share Posted May 20, 2013 Addvice for the future : Dom't use setTimer function with onClientRender event, Makes your server so laggy =) Link to comment
Kenix Posted May 20, 2013 Share Posted May 20, 2013 Addvice for the future : Dom't use setTimer function with onClientRender event, Makes your server so laggy =) Client! Not the server. setTimer( function() local iHour = getTime(); if iHour > 20 and iHour < 6 and not g_bNightTime then setWeather ( 9 ); g_bNightTime = true; elseif iHour > 6 and iHour < 20 and g_bNightTime then setWeather ( 11 ); g_bNightTime = false; end end, 60000, 0 ); Link to comment
iPrestege Posted May 20, 2013 Share Posted May 20, 2013 Addvice for the future : Dom't use setTimer function with onClientRender event, Makes your server so laggy =) Client! Not the server. setTimer( function() local iHour = getTime(); if iHour > 20 and iHour < 6 and not g_bNightTime then setWeather ( 9 ); g_bNightTime = true; elseif iHour > 6 and iHour < 20 and g_bNightTime then setWeather ( 11 ); g_bNightTime = false; end end, 60000, 0 ); I Think client render would be better . Link to comment
Kenix Posted May 20, 2013 Share Posted May 20, 2013 Addvice for the future : Dom't use setTimer function with onClientRender event, Makes your server so laggy =) Client! Not the server. setTimer( function() local iHour = getTime(); if iHour > 20 and iHour < 6 and not g_bNightTime then setWeather ( 9 ); g_bNightTime = true; elseif iHour > 6 and iHour < 20 and g_bNightTime then setWeather ( 11 ); g_bNightTime = false; end end, 60000, 0 ); I Think client render would be better . Why? It makes no sense.. You don't need to call function every frame.. You can call it only each 1 minute and it's more better. For example you need to call a "big" function for calculation or doing something "hard", loop tables with 999 indexes and etc. And you call this function every frame. It makes no sense. I think you understand me. P.S Think about optimization. Not all people have an awesome hardware. Link to comment
iPrestege Posted May 20, 2013 Share Posted May 20, 2013 Client! Not the server. setTimer( function() local iHour = getTime(); if iHour > 20 and iHour < 6 and not g_bNightTime then setWeather ( 9 ); g_bNightTime = true; elseif iHour > 6 and iHour < 20 and g_bNightTime then setWeather ( 11 ); g_bNightTime = false; end end, 60000, 0 ); I Think client render would be better . Why? It makes no sense.. You don't need to call function every frame.. You can call it only each 1 minute and it's more better. For example you need to call a "big" function for calculation or doing something "hard", loop tables with 999 indexes and etc. And you call this function every frame. It makes no sense. I think you understand me. P.S Think about optimization. Not all people have an awesome hardware. Ah yes i get it 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