Jump to content

How To


boro

Recommended Posts

Posted

Please help how to setWeather ( 9 ) when is game time 20:00 ? Exist event for check game timer ?

I'll help When I Can.

Posted

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 

I'll help When I Can.

Posted

addEventHandler("onClientRender",root, 
    function ( ) 
        local h, m = getTime() 
            if h > 20 then 
                setWeather ( 9 ) 
    elseif h < 6 then 
                setWeather ( 11 ) 
            end 
        end 
    ) 

More easy .

  

Posted

Addvice for the future :

Dom't use setTimer function with onClientRender event, Makes your server so laggy =)

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted
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 ); 
  
  

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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

  

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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

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 .

  

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