# Exports

> The following events and exports can be used from your own scripts to interact and/or receive info from the weather script.

{% tabs %}
{% tab title="Client" %}

### zoneUpdated

> This event gets triggered when a zone is updated from server, contains the zone name and a table with zone info.
>
> **params:**
>
> * **zone**: `string`
> * **data:** `table`
>
> ```lua
> AddEventHandler('av_weather:zoneUpdated', function(zone,data)
>     print(zone, json.encode(data,{ indent = true}))
>     --[[
>         data = {
>            wind: number,
>            zone: string,
>            fog: string,
>            windState: string,
>            label: string,
>            weather: string,
>            freeze: boolean,
>            frozenFog: string,
>            temperature: number
>         }
>     ]]--
> end
> ```

### timeUpdated

> This event gets triggered when in game time is updated.
>
> **params:**
>
> * **hours**: `number`
> * **minutes**: `number`
> * **seconds**: `number`
>
> ```lua
> AddEventHandler('av_weather:timeUpdated',function(hours,minutes,seconds)
>     print(hours, minutes, seconds)
> end)
> ```

### Freeze/Unfreeze Time and Weather for local player

> Use this event to freeze or sync the time for a local player, useful for multicharacter, spawn scripts, houses/motel scripts, etc.
>
> params:
>
> * **state**: `Boolean`
> * **hours**: `number` *optional*
> * **minutes**: `number` *optional*
> * **weather**: `string` *optional*
> * **blackout**: `Boolean` *optional*
> * **fog**: `string` *optional*
> * **snow**: `boolean` *optional*
>
> ```lua
> -- This is an example on how to freeze a player time:
> local state = true
> local hours = 23
> local minutes = 0
> local weather = "CLEAR"
> local blackout = false
> local fog = false
> local snow = false -- render snow on ground
> -- Fog options: "automatic", "no", "normal", "low", "medium", "high", "max" or false
> TriggerEvent('av_weather:freeze', state, hours, minutes, weather, blackout, fog, snow)
> ```
>
> ```lua
> -- This is an example on how to unfreeze player time and sync with server
> TriggerEvent('av_weather:freeze', false)
> ```

### getZone()

> Use this export to get the current zone where the player is standing.
>
> **returns:**
>
> **zone**: `table`&#x20;
>
> * **wind:** `float`
> * **zone:** `string`
> * **weather:** `string`
> * **label:** `string`
> * **temperature:** `number`
> * **fog:** `string`
>
> ```lua
> local zone = exports['av_weather']:getZone()
> if zone then
>     print(json.encode(zone, {indent = true}))
>     --[[
>     {
>        "zone": "santos",
>        "label": "Los Santos",
>        "wind": 1.59,
>        "weather": "OVERCAST",
>        "temperature": 23,
>        "fog": "normal",
>     }
>     ]]--
> end
> ```

### getBlackout()

> Use this export to retrieve the current blackout state.
>
> **returns:**
>
> **state**: B`oolean`
>
> ```lua
> local blackout = exports['av_weather']:getBlackout()
> -- blackout = true or false
> ```

### setRain()

> Removes rain effects from the player, useful for those using YMAPs where rain comes through the roof creating puddles inside their map.
>
> **params:**
>
> **state**: `Boolean`
>
> ```lua
> local state = true -- or false to enable effect again
> exports['av_weather']:setRain(state)
> ```

#### localBlackout(state)

> Use this export to trigger a blackout for the local player.
>
> **params:**
>
> * **state**:`boolean`
>
> ```lua
> local state = true -- or false to disable it
> exports['av_weather']:localBlackout(state)
> ```

{% endtab %}

{% tab title="Server" %}

### generateWeathers()

> Use this export to generate random weathers for all zones.
>
> ```lua
> exports['av_weather']:generateWeathers()
> ```

### getZone()

> Retrieve a zone info.
>
> **parameters:**
>
> **name**: `string`
>
> <pre class="language-lua"><code class="lang-lua"><strong>local name = "santos" -- options: "santos", "sandy", "paleto", "cayo
> </strong><strong>local zoneInfo = exports['av_weather']:getZone(name)
> </strong><strong>--[[
> </strong><strong>    zone info returns false or table:
> </strong><strong>    {
> </strong><strong>        zone: string,
> </strong><strong>        label: string,
> </strong><strong>        weather: string,
> </strong><strong>        wind: number,
> </strong><strong>        temperature: number,
> </strong><strong>        freeze: boolean,
> </strong><strong>        fog: string
> </strong><strong>    }
> </strong><strong>]]--
> </strong></code></pre>

### updateZone()

> *Not recommended, use the weather menu instead.*
>
> **parameters:**
>
> **zone:** `string`
>
> **weather:** `string`
>
> **freeze:** `boolean`
>
> ```lua
> local zone = "santos"
> local weather = "THUNDER"
> local freeze = false
> exports['av_weather']:updateZone(zone, weather, freeze)
> ```

### updateTime()

> *Not recommended, use the weather menu instead.*
>
> **parameters:**
>
> **hour:** `number`
>
> **minutes:** `number`
>
> **freeze:** `boolean`
>
> **instant:** `boolean`
>
> ```lua
> local hour = 20
> local minutes = 0
> local freeze = false
> local instant = false -- if false then time will increase progressively
> exports['av_weather']:updateTime(hour, minutes, freeze, instant)
> ```

### setBlackout()

> Change the blackout state for all server players.
>
> **parameters:**
>
> **state**: `Boolean`
>
> ```lua
> local state = true -- enable/disable blackout globally
> exports['av_weather']:setBlackout(state)
> ```

### getBlackout()

> Get the server blackout state.
>
> **returns**
>
> **state**: `Boolean`
>
> ```lua
> local state = exports['av_weather']:getBlackout()
> ```

### getTime()

> Get server time.
>
> **returns**
>
> **value**: `table`
>
> ```lua
> local serverTime = exports['av_weather']:getTime()
> print(json.encode(serverTime, {indent = true}))
> --[[
>     serverTime = {
>         hour: number,
>         minutes: number,
>         seconds: number
>     }
> ]]--
> ```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.av-scripts.com/guides/weather-script/exports.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
