> 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

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

<figure><img src="/files/sjRNyXYapIYzoKZv3tHE" 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>
