Environment Systems - Time-Of-Day and Weather for your server

Because no server is complete without a good sunset.

Got questions? Check the FAQ before posting, you may already have an answer!

Media

http://puu.sh/4IjG8.jpg

http://puu.sh/4IjJt.jpg

http://puu.sh/4IjL4.jpg

Convars and commands
Server

Client

Download
GitHub: https://github.com/MyHatStinks/EnvironmentSystem
Steam Workshop: http://steamcommunity.com/sharedfiles/filedetails/?id=183082572

FAQ
Can I disable weather and just use the time of day system?
Yes, if you set weather_random to 0 server-side, the weather will always default to “sun” unless changed manually by an administrator.

Can I disable the time of day system and just use the weather system?
Currently, no, this is not possible.

I have some indoor/underground maps, is it possible to disable this addon for these specific maps?
Yes, of course! There is a lua file named sh_weather_blacklist.lua, all the information you need should be in there. If a map does not have an entry in this file, it will always have both time of day and weather.

I want to remove a default weather, how would I do this?
All default weathers are created in autorun/sh_weather.lua. If you want to remove a weather, find the appropriate line here and delete it.

What are all the default weathers?
All default weathers are lower case. The default weathers are “sun”, “snow”, “rain”, “storm”, and “fog”.

I want to add a new weather, how would I do this?


(Lua coders only!)

All weathers are stored in a global table named “Weather.Effects”. The key should be the name of the weather, and this will be used when an administrator wants to force your weather. All values are optional, the “sun” weather uses all nil. The variables available by default are as follows:

Example entry:
[lua]Weather.Effects[“fire_rain”] = {LightMod = 2, Sound = “ambient/fire/fire_small_loop1.wav”, particle = “SomeFireParticles”, Damage = 1,
StartFunc = function( self ) if SERVER then timer.Create(“FireWeatherDamage”, 0.2, 0, function() for _,v in pairs(player.GetAll()) do v:TakeDamage( self.Damage, v, v ) end) end end,
EndFunc = function( self ) if SERVER then timer.Remove( “FireWeatherDamage” ) end end}[/lua]

Are the convars persistent?
Should be. I’m not sure if the client convars will stick if you change to another server running the addon, but if you rejoin the same one it should stay the same. For server side convars, they are persistent, but you should be probably be using server.cfg anyway.

Will the weather stay the same across map changes?
No, the weather will be randomised every map. Unless you have random weather disabled, in which case it will revert back to your set default.

Can I modify/redistribute/sell all or part of this addon?
Yes, but it would be bad manners to claim you created it all yourself

Will you add X?
That depends, is it useful for everyone or just something you want for yourself or your server?

How do I make something happen at a certain time?


(Lua coders only!)

(Thanks to thelastpengiun for the suggestion)
There are hooks available for every minute change or every hour change, depending on how frequently you want to run your function. The hook “TimeOfDayMinute” will run every time there is a minute update, and is passed two number arguments for the current hour and minute. The hook “TimeOfDayHour” will run every time there is an hour update, and is passed a number argument for the new hour. Both of these hooks are server-side.
Example usage:
[lua]hook.Add( “TimeOfDayMinute”, “Game Clock”, function( h, m )
local h,m = tostring(h), tostring(m)
if #h==1 then h=“0”…h end
if #m==1 then m=“0”…m end
BroadcastLua( [[chat.AddText( “The time is now ]]…h…[[:]]…m…[[” )]] )
end)[/lua]
[lua]hook.Add( “TimeOfDayHour”, “Check Night”, function( h )
if h<5 or h>20 then --It’s night
AllowZombieSpawn = true
end
end)[/lua]

Those clouds are ugly!
Not really a question, but yes, they are. Can you make better, working, tileable clouds in .vtf format? If so, would you share? ^^

Where is the download link?
Scroll up, you missed it.

Nice job.

This looks rather impressive, the only complaint I would have is that when it gets dark the ground doesn’t decrease in brightness along with the sky. I think Garry added the ability to do this in one of his recent updates so I definetly think that’s something worth looking into, otherwise great work :smiley:

Already does

Here’s some side-by-side screenshots

Nice job! Would use this on my TTT server if you had a way to blacklist maps. Looking forward to see if you do that or not.

Good job, Hope to see more projects out of you :wink:

All I have to say is wow, this is a truly incredible mod that must have taken a huge amount of time and effort and the results show it. I’ve been watching the videos and it’s probably the nicest sunrise / sunset and general weather I have seen out of a mod of this kind. Keep up the awesome work.

Also including the info on making weather paturns for developers was a nice touch since many coders, such as myself, i know will be excited to see their own super-storms in action.

A hook for when it toggles state between day / night would be good if there isnt one already. It’d be nice for developers to make something happen on sunrise / sunset. On one of my servers im planning to use this to enable / disable zombie spawning at night.

EDIT:
You should check the sizes on your materials and wave file… they are huge making it difficult for server usage. Something you may wish to considder.

You should probably state that the map has to have a 3d skybox.

Just updated, the sound file is now a lot smaller. I think the materials won’t be too bad, just until I get a less ugly replacement

If it’s really a problem, the resource.AddFile lines are in autorun/shared.lua, just remove the Clouds variable from the snow, rain, and storm effects and they’ll revert to the standard stars at night and faint clouds during day

I’ve added some hooks for you, “TimeOfDayMinute” and “TimeOfDayHour”, the minute hook gets passed the new hour and minute, the hour hook gets passed the new hour. Your sunrise should be about hour 5, and sunset about hour 21. I’ll add more detailed usage info to the FAQs

Didn’t know that, all the maps I tested on had a 3D skybox. I’ll add it to the FAQs, thanks

[editline]9th January 2013[/editline]

Added an sh_weather_blacklist.lua, should be an easy way to blacklist now. It’s just a case of copying a line and putting the map name in it, for example to blacklist both time and weather on example_map.bsp you’d use:
[lua]b[“example_map”] = {time = true, weather = true}[/lua]

This is a great addon but the lighting of the map itself does not change with the time of day, for example whenever it is night time the street and buildings look exactly like they did in the day time.

I have a server running this on darkrp, I’m not sure what advertising rules are here so I won’t post the ip but if you’d like to see it etc let me know.

Ok the buildings seem to change but the street does not.

Here is what it looks like at day time:

http://cloud.steampowered.com/ugc/613880891140936184/EFD96E9E233ABC7770C575D9BEC8963CAE1C328A/

Here is what it looks like at night:

http://cloud-2.steampowered.com/ugc/613880891140938630/6C84C608CD2D4E91009A08BFDAFE2331C8D6430F/

Here’s some feedback I have gotten on your weather mod on my community forums. I have modified it a little bit but the comments are features I have left mainly unaltered. http://http://www.lastpenguin.com/showthread.php?tid=513&pid=2502#pid2502

They say as a basic summary: The rain is a bit too loud by default. Possible decrease volume more indoors?

Rain effects go through roof: Looking at ur code I think it’s the splashes they are seeing… Must be a way to fix this though I’m not sure how without some more extensive understanding of the effects.

FPS issues for a lot of people on rain. Change rain levels based on measured FPS?

Thanks for the feedback

Default volume decreased to 0.2, but since it’s a persistent setting it won’t change automatically for everyone. Tell your regulars they should use the console command “weather_volume 0.2”

The splashes are fixed, they don’t spawn above the player now. There might still be leaks in small crawlspaces with large open areas above them, but I’m sure someone can imagine some legitimate excuse for that. The number of splash effects have been reduced thanks too, so it’ll sound less like “a fat guy fapping off”, as your users put it

Performance should be improved considerably for the default setting. If your players are still having fps issues, tell them to make use of the “weather_performance_mode [0/1/2]” settings

-snip-
nevermind.

Is there any way i could use a vtf as the moon instead of a coded one or would that be impossible?

Also when i set the weather to fog there doesn’t seem to be any fog.

In console weather_systemtime 0 nor does weather_daylength work for me just says unknown, when i try edit the values in the file whenever I connect I get the Bad Challenge error.

That’s not possible, sorry

About the fog, have you modified the sv or cl files? If so, what have you changed?

Are you changing them server-side, ie through rcon?

When I tried rcon there was no return message nor did anything come up in the server console.

Try running “weather_systemtime 0;weather_daylength 1”, if the sun goes flying across the sky it’s working properly, if it doesn’t post back here

Tell me of any modifications you’ve made, tell me if there’s any errors, and tell me what map you’re using

I have fixed it, is there any way of removing the extremely red part of the sunrise?