Padul Posted June 22, 2016 Share Posted June 22, 2016 can you help me guys? i wrote down some script which had to change weather and some sky gradient, but it doesnt work, can you help me with it? local time = getRealTime() local hour = time.hour function nuclearWeather () if (hour >= 1) and (hour <= 5) then setFarClipDistance( 70 ) setFogDistance ( 30 ) setSkyGradient(0,0,0,0,0,0) setWeather ( 22 ) setCloudsEnabled ( false ) setSunSize ( 0 ) elseif (hour > 5) and (hour <= 7) then setFarClipDistance( 120 ) setFogDistance ( 70 ) setSkyGradient( 0, 14, 12, 14, 13.5, 10 ) setWeather ( 3 ) setCloudsEnabled ( false ) setSunSize ( 2 ) elseif (hour > 7) and (hour <= 11) then setFarClipDistance( 220 ) setFogDistance ( 170 ) setSkyGradient( 0, 89, 196, 136, 170, 180 ) setWeather ( 4 ) setCloudsEnabled ( true ) setSunSize ( 2 ) elseif (hour == 20) then setFarClipDistance( 180 ) setFogDistance ( 100 ) setSkyGradient( 25, 25, 25, 25, 25, 25 ) setWeather ( 8 ) setRainLevel ( 1.8 ) setWindVelocity ( 0.3, 0.1, 0 ) setCloudsEnabled ( true ) setSunSize ( 2 ) else setFarClipDistance( 240 ) setFogDistance ( 150 ) resetSkyGradient() setWeather ( 4 ) setCloudsEnabled ( true ) setWindVelocity ( 0, 0, 0 ) setSunSize ( 3 ) end setWaveHeight ( 0 ) end setTimer(nuclearWeather,1000,0) Link to comment
Bean666 Posted June 22, 2016 Share Posted June 22, 2016 remove your local hour and try replacing it with this: local hour, minute = getTime ( ) no need to edit the if (hour) stuff. Link to comment
Padul Posted June 22, 2016 Author Share Posted June 22, 2016 its working a little, it changes weather everytime i restart script, but not from itself local hour, minute = getTime () function nuclearWeather () if (hour >= 1) and (hour <= 5) then setFarClipDistance( 70 ) setFogDistance ( 30 ) setSkyGradient(0,0,0,0,0,0) setWeather ( 22 ) setCloudsEnabled ( false ) setSunSize ( 0 ) elseif (hour > 5) and (hour <= 7) then setFarClipDistance( 120 ) setFogDistance ( 70 ) setSkyGradient( 0, 14, 12, 14, 13.5, 10 ) setWeather ( 3 ) setCloudsEnabled ( false ) setSunSize ( 2 ) elseif (hour > 7) and (hour <= 11) then setFarClipDistance( 220 ) setFogDistance ( 170 ) setSkyGradient( 0, 89, 196, 136, 170, 180 ) setWeather ( 4 ) setCloudsEnabled ( true ) setSunSize ( 2 ) elseif (hour == 20) then setFarClipDistance( 180 ) setFogDistance ( 100 ) setSkyGradient( 25, 25, 25, 25, 25, 25 ) setWeather ( 8 ) setRainLevel ( 1.8 ) setWindVelocity ( 0.3, 0.1, 0 ) setCloudsEnabled ( true ) setSunSize ( 2 ) else setFarClipDistance( 240 ) setFogDistance ( 150 ) resetSkyGradient() setWeather ( 4 ) setCloudsEnabled ( true ) setWindVelocity ( 0, 0, 0 ) setSunSize ( 3 ) setWaveHeight ( 0 ) end end setTimer(nuclearWeather,1000,0) if i set server time manualy to eg 20 then it will change the weather, but if the time will change by the time lapse the weather wont change Link to comment
Tails Posted June 22, 2016 Share Posted June 22, 2016 Put the time vars in your function like so: function nuclearWeather () local time = getRealTime() local hour = time.hour if (hour >= 1) and (hour <= 5) then setFarClipDistance( 70 ) setFogDistance ( 30 ) ........... When you put the time fuction outside the timer you'll only get the time once. You need to get it every time. Link to comment
Padul Posted June 23, 2016 Author Share Posted June 23, 2016 Put the time vars in your function like so: function nuclearWeather () local time = getRealTime() local hour = time.hour if (hour >= 1) and (hour <= 5) then setFarClipDistance( 70 ) setFogDistance ( 30 ) ........... When you put the time fuction outside the timer you'll only get the time once. You need to get it every time. i made mistake and i wanted to put there server time, not real time ok i made few modifications and i noticed that script works everytime i start it and its not in function kappa something like this --function nuclearWeather () local hour = getTime (hour) if (hour >= 1) and (hour <= 5) then setFarClipDistance( 70 ) setFogDistance ( 30 ) setSkyGradient(0,0,0,0,0,0) setWeather ( 22 ) setCloudsEnabled ( false ) setSunSize ( 0 ) elseif (hour > 5) and (hour <= 7) then setFarClipDistance( 120 ) setFogDistance ( 70 ) setSkyGradient( 0, 14, 12, 14, 13.5, 10 ) setWeather ( 3 ) setCloudsEnabled ( false ) setSunSize ( 2 ) elseif (hour > 7) and (hour <= 11) then setFarClipDistance( 220 ) setFogDistance ( 170 ) setSkyGradient( 0, 89, 196, 136, 170, 180 ) setWeather ( 4 ) setCloudsEnabled ( true ) setSunSize ( 2 ) elseif (hour == 20) then setFarClipDistance( 180 ) setFogDistance ( 100 ) setSkyGradient( 25, 25, 25, 25, 25, 25 ) setWeather ( 8 ) setWindVelocity ( 0.3, 0.1, 0 ) setCloudsEnabled ( true ) setSunSize ( 2 ) else setFarClipDistance( 240 ) setFogDistance ( 150 ) resetSkyGradient() setWeather ( 4 ) setCloudsEnabled ( true ) setWindVelocity ( 0, 0, 0 ) setSunSize ( 3 ) setWaveHeight ( 0 ) end setTimer(nuclearWeather,5000,0) --end do you think that adding event handler will help? Link to comment
Overkillz Posted June 23, 2016 Share Posted June 23, 2016 It should work now setTimer(function() local time = getRealTime() local hours = time.hour if hours >= 1 and hours <= 5 then setFarClipDistance( 70 ) setFogDistance ( 30 ) setSkyGradient(0,0,0,0,0,0) setWeather ( 22 ) setCloudsEnabled ( false ) setSunSize ( 0 ) elseif hours > 5 and hours <= 7 then setFarClipDistance( 120 ) setFogDistance ( 70 ) setSkyGradient( 0, 14, 12, 14, 13.5, 10 ) setWeather ( 3 ) setCloudsEnabled ( false ) setSunSize ( 2 ) elseif hours > 7 and hours <= 11 then setFarClipDistance( 220 ) setFogDistance ( 170 ) setSkyGradient( 0, 89, 196, 136, 170, 180 ) setWeather ( 4 ) setCloudsEnabled ( true ) setSunSize ( 2 ) elseif hours == 20 then setFarClipDistance( 180 ) setFogDistance ( 100 ) setSkyGradient( 25, 25, 25, 25, 25, 25 ) setWeather ( 8 ) setRainLevel ( 1.8 ) setWindVelocity ( 0.3, 0.1, 0 ) setCloudsEnabled ( true ) setSunSize ( 2 ) else setFarClipDistance( 240 ) setFogDistance ( 150 ) resetSkyGradient() setWeather ( 4 ) setCloudsEnabled ( true ) setWindVelocity ( 0, 0, 0 ) setSunSize ( 3 ) end setWaveHeight ( 0 ) end,1000,0) The problem was that you are not updating the real time. Now it should works ( Not tested ) Link to comment
Padul Posted June 23, 2016 Author Share Posted June 23, 2016 It should work now setTimer(function() local time = getRealTime() local hours = time.hour if hours >= 1 and hours <= 5 then setFarClipDistance( 70 ) setFogDistance ( 30 ) setSkyGradient(0,0,0,0,0,0) setWeather ( 22 ) setCloudsEnabled ( false ) setSunSize ( 0 ) elseif hours > 5 and hours <= 7 then setFarClipDistance( 120 ) setFogDistance ( 70 ) setSkyGradient( 0, 14, 12, 14, 13.5, 10 ) setWeather ( 3 ) setCloudsEnabled ( false ) setSunSize ( 2 ) elseif hours > 7 and hours <= 11 then setFarClipDistance( 220 ) setFogDistance ( 170 ) setSkyGradient( 0, 89, 196, 136, 170, 180 ) setWeather ( 4 ) setCloudsEnabled ( true ) setSunSize ( 2 ) elseif hours == 20 then setFarClipDistance( 180 ) setFogDistance ( 100 ) setSkyGradient( 25, 25, 25, 25, 25, 25 ) setWeather ( 8 ) setRainLevel ( 1.8 ) setWindVelocity ( 0.3, 0.1, 0 ) setCloudsEnabled ( true ) setSunSize ( 2 ) else setFarClipDistance( 240 ) setFogDistance ( 150 ) resetSkyGradient() setWeather ( 4 ) setCloudsEnabled ( true ) setWindVelocity ( 0, 0, 0 ) setSunSize ( 3 ) end setWaveHeight ( 0 ) end,1000,0) The problem was that you are not updating the real time. Now it should works ( Not tested ) i wanted it to get server time, not real kappa so i changed local time = getRealTime() local hours = time.hour to local time = getTime() local hours = time.hour ERROR: .../weather.lua:4:attempt to index local 'time' Link to comment
Overkillz Posted June 23, 2016 Share Posted June 23, 2016 getRealTime is a shared function. Using it as serverside it will give you the current time IN THE SERVER. Regards. Link to comment
Padul Posted June 23, 2016 Author Share Posted June 23, 2016 getRealTime is a shared function.Using it as serverside it will give you the current time IN THE SERVER. Regards. yeah but ingame time is sometimes diffrent than real time, do you got my point? Link to comment
Overkillz Posted June 23, 2016 Share Posted June 23, 2016 Not really. might are u getting the same doubt that I got some months ago. I tried to do a welcome message depending of the time of the player. I was using it as server side, then I didnt know why the players were getting other time, till I read that using getRealTime() as client side you will get the time of the player. I really cant understand your point yet. Sorry. Link to comment
Padul Posted June 23, 2016 Author Share Posted June 23, 2016 so my intention was to change server weather setting depens on what the currnet ingame time is, eg if the ingame is 20, then the script will set weather to eg 4, also i set the script to server side Link to comment
Overkillz Posted June 23, 2016 Share Posted June 23, 2016 I thinnk I got you, and as I saw on your comments, you are taking bad the variable getTime() Try this: setTimer(function() local hours, minutes = getTime() if hours >= 1 and hours <= 5 then setFarClipDistance( 70 ) setFogDistance ( 30 ) setSkyGradient(0,0,0,0,0,0) setWeather ( 22 ) setCloudsEnabled ( false ) setSunSize ( 0 ) elseif hours > 5 and hours <= 7 then setFarClipDistance( 120 ) setFogDistance ( 70 ) setSkyGradient( 0, 14, 12, 14, 13.5, 10 ) setWeather ( 3 ) setCloudsEnabled ( false ) setSunSize ( 2 ) elseif hours > 7 and hours <= 11 then setFarClipDistance( 220 ) setFogDistance ( 170 ) setSkyGradient( 0, 89, 196, 136, 170, 180 ) setWeather ( 4 ) setCloudsEnabled ( true ) setSunSize ( 2 ) elseif hours == 20 then setFarClipDistance( 180 ) setFogDistance ( 100 ) setSkyGradient( 25, 25, 25, 25, 25, 25 ) setWeather ( 8 ) setRainLevel ( 1.8 ) setWindVelocity ( 0.3, 0.1, 0 ) setCloudsEnabled ( true ) setSunSize ( 2 ) else setFarClipDistance( 240 ) setFogDistance ( 150 ) resetSkyGradient() setWeather ( 4 ) setCloudsEnabled ( true ) setWindVelocity ( 0, 0, 0 ) setSunSize ( 3 ) end setWaveHeight ( 0 ) end,1000,0) Link to comment
Padul Posted June 23, 2016 Author Share Posted June 23, 2016 ok, now its fine and working, big thanks for help 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