# qb-weathersync: synchronized weather and time

`qb-weathersync` manages shared weather, in-game time, weather transitions, time freezing and blackouts. This guide follows [commit f7ae442](https://github.com/qbcore-fivem/qb-weathersync/tree/f7ae442137ff0cd2e62fee75e2f963465c5429be).

## Installation

Start `qb-core` before `qb-weathersync`. Remove or disable conflicting time/weather owners before enabling the resource. Confirm clients receive the current state after joining or restarting the resource.

## Configuration

The real [`config.lua`](https://github.com/qbcore-fivem/qb-weathersync/blob/f7ae442137ff0cd2e62fee75e2f963465c5429be/config.lua) exposes:

| Key | Default | Purpose |
| --- | --- | --- |
| `Config.DynamicWeather` | `true` | Automatic transitions |
| `Config.StartWeather` | `'EXTRASUNNY'` | Initial weather |
| `Config.BaseTime` | `8` | Initial time |
| `Config.TimeOffset` | `0` | Time adjustment |
| `Config.FreezeTime` | `false` | Whether clock advances |
| `Config.Blackout` | `false` | Blackout state |
| `Config.BlackoutVehicle` | `false` | Blackout behavior for vehicles |
| `Config.NewWeatherTimer` | `10` | Minutes between weather changes |
| `Config.Disabled` | `false` | Disable resource-controlled weather |
| `Config.RealTimeSync` | `false` | Real-world time synchronization |
| `Config.AvailableWeatherTypes` | Weather strings | Allowed weather values |

~~~lua filename="config.lua"
Config.DynamicWeather = true
Config.StartWeather = 'EXTRASUNNY'
Config.NewWeatherTimer = 10
Config.RealTimeSync = false
~~~

## Server controls

The [server code](https://github.com/qbcore-fivem/qb-weathersync/blob/f7ae442137ff0cd2e62fee75e2f963465c5429be/server.lua) registers API names such as `setWeather`, `setTime`, `setBlackout`, `setTimeFreeze`, `setDynamicWeather` and status helpers `getWeatherState` / `getTime`. The code also checks permissions before admin-triggered weather/time changes (`admin` or appropriate ACE/console authority).

Do not accept a client-chosen weather value/time as permission to change global server state. Integrations should use the supported **server-side** interface and their own authorization checks.

## Troubleshooting

| Symptom | Check |
| --- | --- |
| Weather changes but resets | A second weather owner, `DynamicWeather` and server restart defaults |
| Time never progresses | `FreezeTime` or `RealTimeSync` |
| Players see different weather | Resource startup, sync request event and client console |
| Blackout affects unexpected systems | `Blackout` and `BlackoutVehicle` |
| Admin command denied | QBCore permissions and ACE, not a client-side job label |

## Update checklist

1. Pin installed upstream version and keep only one time/weather owner.
2. Test state sync on first join, reconnect and resource restart.
3. Test admin/unauthorized access to weather and time-changing paths.
4. Verify time freeze, real-time sync and blackout independently.

## Sources

[Repository](https://github.com/qbcore-fivem/qb-weathersync/tree/f7ae442137ff0cd2e62fee75e2f963465c5429be) · [Config](https://github.com/qbcore-fivem/qb-weathersync/blob/f7ae442137ff0cd2e62fee75e2f963465c5429be/config.lua) · [Server exports and commands](https://github.com/qbcore-fivem/qb-weathersync/blob/f7ae442137ff0cd2e62fee75e2f963465c5429be/server.lua)
