Environment Systems - Time-Of-Day and Weather for your server
93 replies, posted
Because no server is complete without a good sunset.
Got questions? Check the FAQ before posting, you may already have an answer!
[b][u]Media[/b][/u]
[img]http://puu.sh/4IjG8.jpg[/img]
[img]http://puu.sh/4IjJt.jpg[/img]
[img]http://puu.sh/4IjL4.jpg[/img]
[b][u]Convars and commands[/b][/u]
[b]Server[/b]
[quote][b]weather_force [Weather][/b] Set a specific weather. Rcon or SuperAdmin only. Default weathers are all lower case.
[b]weather_rand[/b] Randomise the weather. Rcon or SuperAdmin only.
[b]weather_systemtime [0/1][/b] Use the server's system time as the current time of day. Default "1".
[b]weather_daylength [1+][/b] Set the length of a day in minutes. Ignored unless weather_systemtime is 0. Default "60".
[b]weather_random [0/1][/b] Use the random weather system. Default "1".
[b]weather_default [Weather][/b] Set a default weather. Ignored unless weather_random is 0. Default "sun". Default weathers are all lower case.[/quote]
[b]Client[/b]
[quote][b]weather_volume [0-1][/b] Set the volume of weather sound loops. Default "0.5".
[b]weather_hud_effects [0/1][/b] Enable the hud effects for weathers which use them. Default "1". (Personally, I think disabling this ruins the effect a little)[/quote]
[b][u]Download[/b][/u]
[b]GitHub:[/b] [url]https://github.com/MyHatStinks/EnvironmentSystem[/url]
[b]Steam Workshop:[/b] [url]http://steamcommunity.com/sharedfiles/filedetails/?id=183082572[/url]
[b][u]FAQ[/b][/u]
[b]Can I disable weather and just use the time of day system?[/b]
Yes, if you set [b]weather_random[/b] to [b]0[/b] server-side, the weather will always default to "sun" unless changed manually by an administrator.
[b]Can I disable the time of day system and just use the weather system?[/b]
Currently, no, this is not possible.
[b]I have some indoor/underground maps, is it possible to disable this addon for these specific maps?[/b]
Yes, of course! There is a lua file named [b]sh_weather_blacklist.lua[/b], 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.
[b]I want to remove a default weather, how would I do this?[/b]
All default weathers are created in [b]autorun/sh_weather.lua[/b]. If you want to remove a weather, find the appropriate line here and delete it.
[b]What are all the default weathers?[/b]
All default weathers are lower case. The default weathers are "sun", "snow", "rain", "storm", and "fog".
[b]I want to add a new weather, how would I do this?[/b] [highlight](Lua coders only!)[/highlight]
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:
[quote][b]Clouds = "Material Path"[/b] A [u].vtf[/u] file to use as the cloud material.
[b]CSize = 1[/b] The scale of the cloud texture.
[b]Sound = "Sound Path"[/b] A [u].wav[/u] file to be looped while the weather is active. Mp3 files may cause issues.
[b]RandomEffect= function() end[/b] A function to run server-side periodically. This is used to flash the sky for "storm" lightning.
[b]RandomClientEffect= function() end[/b] A function to run client-side periodically. This is used to play "storm" thunder sounds.
[b]HUD = "Material Path"[/b] A [u].vmt[/u] file to use for HUD effects. This is used during "rain" to display water droplets on the hud.
[b]particle = "Particle"[/b] A particle system to use for the weather effects.
[b]StartFunc = function() end[/b] A function to call whenever the weather starts. Used on both client and server. Used to create fog during the "fog" weather.
[b]EndFunc= function() end[/b] A function to call whenever the weather ends. Used on both client and server. Used to remove fog after the "fog" weather.
[b]LightMod = 0[/b] Modify the light level by this amount during this weather. Note that there is a cap on the minimum light level, to prevent the map going pitch black.[/quote]
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]
[b]Are the convars persistent?[/b]
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.
[b]Will the weather stay the same across map changes?[/b]
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.
[b]Can I modify/redistribute/sell all or part of this addon?[/b]
Yes, but it would be bad manners to claim you created it all yourself
[b]Will you add X?[/b]
That depends, is it useful for everyone or just something you want for yourself or your server?
[b]How do I make something happen at a certain time?[/b] [highlight](Lua coders only!)[/highlight] (Thanks to [url="http://www.facepunch.com/showthread.php?t=1238171&p=39152021&viewfull=1#post39152021"]thelastpengiun[/url] 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]
[b]Those clouds are ugly![/b]
Not really a question, but yes, they are. Can you make better, working, tileable clouds in .vtf format? If so, would you share? ^^
[b]Where is the download link?[/b]
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 :D
[QUOTE=JG215;39145729]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 :D[/QUOTE]
Already does
Here's some side-by-side screenshots
[url]http://steamcommunity.com/sharedfiles/filedetails/?id=119039490[/url]
[url]http://steamcommunity.com/sharedfiles/filedetails/?id=119039419[/url]
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 ;)
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.
[QUOTE=thelastpenguin;39152021]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.[/QUOTE]
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
[QUOTE=BloodRayne;39152449]You should probably state that the map has to have a 3d skybox.[/QUOTE]
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]
[QUOTE=CaptainFab;39146821]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.[/QUOTE]
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:
[IMG]http://cloud.steampowered.com/ugc/613880891140936184/EFD96E9E233ABC7770C575D9BEC8963CAE1C328A/[/IMG]
Here is what it looks like at night:
[IMG]http://cloud-2.steampowered.com/ugc/613880891140938630/6C84C608CD2D4E91009A08BFDAFE2331C8D6430F/[/IMG]
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. [URL]http://http://www.lastpenguin.com/showthread.php?tid=513&pid=2502#pid2502[/URL]
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?
[QUOTE=thelastpenguin;39178935]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?[/QUOTE]
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.
[QUOTE=RCRad;39192472]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.[/QUOTE]
That's not possible, sorry
About the fog, have you modified the sv or cl files? If so, what have you changed?
[QUOTE=Cohen;39204162]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.[/QUOTE]
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.
[QUOTE=Cohen;39204328]When I tried rcon there was no return message nor did anything come up in the server console.[/QUOTE]
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?
[QUOTE=Cohen;39207472]I have fixed it, is there any way of removing the extremely red part of the sunrise?[/QUOTE]
Of course, in the server-side file at lines 13-40 you should find what you need. The table keys correspond to the hour. Sunrise should be about 6-10, sunset at about 17-20.
You'll want to modify the "bot" and "dusk" fields, try not to modify the "light" field, I put a minimum on it further into the code
[QUOTE=Cohen;39204328]When I tried rcon there was no return message nor did anything come up in the server console.[/QUOTE]
check the addon folder, if there's a map called trunk in it you should pull the contents of that to the environment thing folder
and my_hat_stinks, thank you for this, i'm in love.
Using it on darkrp now works too well in a good way ;)
ikr
Some players can see this and some only see a checkerboard sky. What is required for players to see this?
it's probably because fastdl is broken
anyway, if i want to make it darker, which value do i edit?
[QUOTE=k9o0df1;39442295]anyway, if i want to make it darker, which value do i edit?[/QUOTE]
I put a cap on the light at "b" (It uses letters, little annoying), in my tests when it went to "a" everything went pitch black
However, if you still want to decrease the light level, sv_weather.lua line 113, edit
[lua]local level = math.max( 98, TimeLighting[Time.h].light + weather )[/lua]
to change the minimum light level
To change the light level for times of day, lines 13-40, the "light" variables, and to change the light level for specific weathers, that would be the "lightmod" variable in the weather entry
Hey, wait up, do I decrease the number 98 for the min light level to decrease?
yay stupid questions
-oh hello jack noir, cyrus here.
-ontopic: tried to decrease lightlevel, whole map wen't black, not trying again D:
[QUOTE=Brandon1995;39158641]Ok the buildings seem to change but the street does not.
Here is what it looks like at day time:
[IMG]http://cloud.steampowered.com/ugc/613880891140936184/EFD96E9E233ABC7770C575D9BEC8963CAE1C328A/[/IMG]
Here is what it looks like at night:
[IMG]http://cloud-2.steampowered.com/ugc/613880891140938630/6C84C608CD2D4E91009A08BFDAFE2331C8D6430F/[/IMG][/QUOTE]
Second, feels really funny having bright streets and a dark skybox.
Sorry, you need to Log In to post a reply to this thread.