> For the complete documentation index, see [llms.txt](https://docs.vames-store.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vames-store.com/assets/vms_needs/compatibility/weather/vsync.md).

# vSync

{% hint style="warning" %}
Only add the highlighted lines. Do not replace the existing vSync code.
{% endhint %}

***

#### 1. Open the file

Open the following file: **vSync/vs\_server.lua**

#### 2. Synchronize weather and time

Find the `vSync:requestSync` event and add the highlighted lines inside it.

<pre class="language-lua"><code class="lang-lua">RegisterServerEvent('vSync:requestSync')
AddEventHandler('vSync:requestSync', function()
    -- Your existing code...

    -- ===== VMS Needs =====
<strong>    local hour = math.floor(((baseTime+timeOffset)/60)%24)
</strong><strong>    local minute = math.floor((baseTime+timeOffset)%60)
</strong><strong>    TriggerEvent('vms_needs:temperature:update', CurrentWeather, hour, minute)
</strong>    -- =====================
end)
</code></pre>

#### 3. Synchronize time updates

Find the thread responsible for updating the in-game time and add the highlighted lines inside it.

<pre class="language-lua"><code class="lang-lua">Citizen.CreateThread(function()
    while true do
        Citizen.Wait(5000)
        TriggerClientEvent('vSync:updateTime', -1, baseTime, timeOffset, freezeTime)
        
        -- ===== VMS Needs =====
<strong>        local hour = math.floor(((baseTime+timeOffset)/60)%24)
</strong><strong>        local minute = math.floor((baseTime+timeOffset)%60)
</strong><strong>        TriggerEvent('vms_needs:temperature:updateTime', hour, minute)
</strong>        -- =====================
    end
end)
</code></pre>

#### 4. Synchronize weather updates

Find the thread responsible for updating the weather and add the highlighted line inside it.

<pre class="language-lua"><code class="lang-lua">Citizen.CreateThread(function()
    while true do
        Citizen.Wait(300000)
        TriggerClientEvent('vSync:updateWeather', -1, CurrentWeather, blackout)

        -- ===== VMS Needs =====
<strong>        TriggerEvent('vms_needs:temperature:updateWeather', CurrentWeather)
</strong>        -- =====================
    end
end)
</code></pre>

#### 5. Initiate the first synchronization after the server starts up

Add the following thread at the end of the file.

```lua
Citizen.CreateThread(function()
    Citizen.Wait(10000)
    
    local hour = math.floor(((baseTime+timeOffset)/60)%24)
    local minute = math.floor((baseTime+timeOffset)%60)
    TriggerEvent('vms_needs:temperature:update', CurrentWeather, hour, minute)
end)
```
