Jump to content

[REL] Churchill's BetterWeather system v1.0


churchill

Recommended Posts

https://community.multitheftauto.com/index.php?p=resources&s=details&id=199

My first attempted resource/script - something basic, but might be useful to others.

I've noticed that most weather scripts seem to be a bit basic in that they just randomly change the weather at a fixed time. Sometimes they go one step further and change it at a random time. What this resource does is attempt to mimic weather patterns by setting today's weather but also pre-defining potential weather for 2 days ahead, for both the day and night weather.

When the weather updates each day it's based on these pre-defined "predictions". As with real weather, it's not 100% accurate - sometimes the weather prediction can be wrong for the days ahead when we actually get to tomorrow or the next day :)

It is also a little random in that it won't change at a set time every day/night.

Day time changes come into effect between 7am and midday. Night time weather comes into effect after 8pm, but before midnight.

Included in the resource is weather report window, activated by hitting F5, but that key is defineable in an optional.xml config file, if you unzip the file into a folder.

Additionally, the resource has export functions so that you can send weather descriptions (or IDs) for the days ahead to other resources. I can think of one or two examples where you might want to do that, but I'm not going to give away ideas :)

Note: it only uses one timer at any time, but is set 3 times over the course of a 24 minute day, for the midnight update, daytime update, and evening update.

Second note: I noticed while testing this that the client time seems to slowly go out of sync compared to the server time. because of this, I've added a setTime(getTime()) at the point of each update, in order to keep the server/client times in sync a bit better.

Comments welcome, either here or in the resource comments. Please report bugs, or suggestions for improvements!

Screenshots

The Today Tab changes slightly depending on the time of day you view it. It displays overnight weather alongside the day and evening weather if you're viewing in the early hours of the morning, or just the night weather if you're viewing it after about 7pm onwwards:

342.png

The Tomorrow and Day After tabs just show day and night time weather - so they both generally look like this:

343.png

Link to comment
if you use the setWeather command client-side and add a few huge moving colshapes so the weather changes for you if you enter one of these it should be possible

they'd have to be pretty large colshapes, wouldn't they? :) but I guess you're right.

Are sandstorms predictable, or should they be random events when in the desert?

Link to comment

So, I would keep the world weather as server side, but if you enter a colshape that randomly moves across the desert region, it sets the weather on the client side to sandstorm for that user. When they leave the colshape, the weather reverts back to the server weather?

Sounds straight forward enough. I'll add it to my to-do list.

Link to comment

I wouldn't use collision shapes though. Don't forget that a massive collision shape can cause script lag due to the fast amount of call backs from vehicles/players entering the shape. If you start moving the shape it can get even worse since it will start making the same call backs all over again. My advice would be to setup a pulse timer and periodically check the player position.

Link to comment
  • 2 years later...
  • 1 month later...
  • 4 months later...
  • 6 years later...

[05:20:59] WARNING: Script 'betterweather/BetterWeather.lua' is not encoded in UTF-8.  Loading as ANSI...
[05:20:59] SCRIPT ERROR: betterweather/BetterWeather.lua:1: unexpected symbol near '?'
[05:20:59] ERROR: Loading script failed: betterweather/BetterWeather.lua:1: unexpected symbol near '?'

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