> For the complete documentation index, see [llms.txt](https://randolio.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://randolio.gitbook.io/docs/paid-scripts/weather-sync.md).

# Weather Sync

A full weather sync system for your server utilizing statebags for everything. Smooth, modern UI designed and made by myself (open to edit), configurable chance based weather cycles. Supports popular.

<https://randolio.tebex.io/package/6562579>

<figure><img src="https://3824174005-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAe388H3zYCl3SCyQNPaU%2Fuploads%2FIkbhRwUASHqEv8I4kkPC%2Fweather.png?alt=media&amp;token=3934da93-015c-4f9d-b3c0-28dbab72d997" alt=""><figcaption></figcaption></figure>

## YOU MAY NEED TO manually ensure randol\_weather in your server.cfg before other scripts otherwise you may error out.

## Client

```lua
-- Can be used across client scripts to toggle weather sync.
exports.randol_weather:ToggleSync(boolean) -- true or false

-- Gets triggered when time changes. Good as a listener to handle third party resources.
AddEventHandler('randol_weather:client:onTimeChange', function(data)
    -- print(data.hours, data.minutes)
end)
```

## Server

<pre class="language-lua"><code class="lang-lua"><strong>-- List of all global states used to manage sync.
</strong>GlobalState.CURRENT_WEATHER
GlobalState.CURRENT_TIME (GlobalState.CURRENT_TIME.hours, GlobalState.CURRENT_TIME.minutes)
GlobalState.BLACKOUT_STATE,
GlobalState.WEATHER_FROZEN,
GlobalState.TIME_FROZEN

-- Some exports if you're unfamiliar with global states.
exports.randol_weather:SetWeather(weather) -- string 'THUNDER' as an example
exports.randol_weather:SetTime(hours, minutes) -- number: 12, 15
exports.randol_weather:ToggleBlackout(boolean) -- boolean: true or false

-- Gets triggered when time changes. Used as a listener in third party resources.
AddEventHandler('randol_weather:server:onTimeChange', function(data)
    -- print(data.hours, data.minutes)
end)
</code></pre>
