Jump to content

How To


boro

Recommended Posts

is it good ? i dont must test it because am in school :roll::lol:

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

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
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
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
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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...