# Optional Features

## Persistent Weather Settings

#### **Overview**:

The weather settings configured in the in-game UI are saved in the `settings.txt` file and applied when the server starts or when the script is restarted.

#### **Ways to Save the Settings**:

There are three methods to save your weather settings:

1. **Using the UI**:
   * Staff members with the appropriate permissions can select the "Save Settings" option in the UI while in-game.
2. **Automatic Saving on Script Restart**:
   * The settings will automatically be saved whenever the script is stopped or restarted.
3. **Triggering a Server Event**:
   * You can also save the settings by triggering the specified server event at least **30 seconds** before a server restart.

{% tabs %}
{% tab title="client-side to server-side" %}

```lua
TriggerServerEvent('cd_easytime:SaveSettings')
```

{% endtab %}

{% tab title="server-side to server-side" %}

```lua
TriggerEvent('cd_easytime:SaveSettings')
```

{% endtab %}
{% endtabs %}

***

***

## Shell Support

{% hint style="warning" %}
**Note**: If you do not use shells, you can ignore this step.
{% endhint %}

When a player enters or exits a shell, you need to trigger the following client-side event. This will set the time to **11 PM** and change the weather to **CLEAR** for the player's client. This ensures there are no visual anomalies, such as shadows or rain/snow, inside the shell.

{% tabs %}
{% tab title="When entering a shell" %}
{% code title="This is a client-sided event." %}

```lua
TriggerEvent('cd_easytime:PauseSync', true)
```

{% endcode %}
{% endtab %}

{% tab title="When exiting a shell" %}
{% code title="This is a client-sided event." %}

```lua
TriggerEvent('cd_easytime:PauseSync', false)
```

{% endcode %}
{% endtab %}
{% endtabs %}

***

***

## **Tsunami Warning**

1. **Configure the Tsunami Warning Duration**:
   * Set the `Config.TsunamiWarning.time` to define how long the tsunami warning should last.
2. **Triggering the Server Event**:
   * This server event needs to be triggered a specified number of minutes before a server restart.
   * **Example**: If you set `Config.TsunamiWarning.time` to **2 minutes**, you must trigger the event **2 minutes** prior to the restart.
   * The Halloween weather will begin to change immediately, and the blackout and tsunami warning sound will activate **90 seconds** later.
3. **Notes**:
   * The blackout and tsunami warning will start when **3/4** of the `Config.TsunamiWarning.time` has expired.
   * If you use **txAdmin's** scheduled restart feature, you only need to configure `Config.TsunamiWarning.time`. The event will be triggered automatically, so manual triggering is not necessary.

{% tabs %}
{% tab title="client-side to client-side" %}
{% code title="boolean = true or false." %}

```lua
TriggerEvent('cd_easytime:StartTsunamiCountdown', boolean)
```

{% endcode %}
{% endtab %}

{% tab title="client-side to server-side" %}
{% code title="boolean = true or false." %}

```lua
TriggerServerEvent('cd_easytime:StartTsunamiCountdown', -1, boolean)
```

{% endcode %}
{% endtab %}
{% endtabs %}

***

***

## Using Real-Time and Weather

> **Understanding the Real-Time Weather and Time Feature**
>
> The real-time and weather data feature allows your server to access up-to-date atmospheric conditions and accurate time information. It can operate in two ways:
>
> * **Independent Use**: You can configure the system to utilize either real-time weather data or real-time clock data separately, depending on your needs.
> * **Simultaneous Use**: Alternatively, both features can be activated simultaneously to provide players with a fully immersive experience that reflects current weather and time conditions in the real world.
>
> This flexibility enables you to tailor the environment to enhance gameplay and realism.

To use real-time and weather, follow these steps:

1. Set the `Config.APIKey` with your API key from [OpenWeatherMap](https://openweathermap.org/api).
2. Update the configuration settings:
   * Set `Config.Weather.METHOD` to `'real'`.
   * Set `Config.Time.METHOD` to `'real'`.
3. Specify your city:
   * Set `Config.Time.RealTime.city` to your city of choice.
   * Set `Config.Weather.RealWeather.city` to the same city or your preferred location.

***

***

## **Disable vMenu**

The time and weather sync in vMenu must be disabled. To do this make sure your permissions.cfg of vMenu for the time and weather looks like [**this**](https://i.imgur.com/LaBJ8jk.png).

*credits to joe\_mama6969.*
