Time of day

How i can change duration of the day? Ex. 1 gta second is 20 seconds in Real Life and make it compatible with this GitHub - KalinkaGit/vSyncR: vSyncR is a FiveM script to synchronize and control the weather and time.

Go to the server file. server.lua or server/main.lua.
Anyways in this file find this line:
local newBaseTime = os.time(os.date("!*t"))/2 + 360

Change this to your desired time. For this you will have to measure the time IC. Measure how many realtime seconds one IC minute takes. Then you know the result of the equation above. If its like 5 seconds per minute and you want 20 change it to this:
local newBaseTime = os.time(os.date("!*t"))/8 + 360

2 Likes

Thanks, it working, but time on screen is glitching, once it is 06:41, it changes normally to 06:42, 06:43 and suddenly goes back to 06:41, it can be done so that it is all the time 06:41 and after a given time it changes to 06: 42?

In this plugin the client is also doing a time calculation. Go to its client file and look for this code:

Citizen.CreateThread(function()
    local hour = 0
    local minute = 0
    while true do
        Citizen.Wait(0)
        local newBaseTime = baseTime
        if GetGameTimer() - 500  > timer then
            newBaseTime = newBaseTime + 0.25
            timer = GetGameTimer()
        end
        if freezeTime then
            timeOffset = timeOffset + baseTime - newBaseTime			
        end
        baseTime = newBaseTime
        hour = math.floor(((baseTime+timeOffset)/60)%24)
        minute = math.floor((baseTime+timeOffset)%60)
        NetworkOverrideClockTime(hour, minute, 0)
    end
end)

In this thread the baseTime is set as well. Change it to this and you will only get the time set from server. (just as a side note I did no testing on this and it might be not the perfect solution):

Citizen.CreateThread(function()
    local hour = 0
    local minute = 0
    while true do
        Citizen.Wait(500) -- change ticking to 500ms, its not needed to run every frame
       -- comment out to prevent client time calculation
       --  local newBaseTime = baseTime
       -- if GetGameTimer() - 500  > timer then
       --     newBaseTime = newBaseTime + 0.25
       --    timer = GetGameTimer()
       --  end
        if freezeTime then
            timeOffset = timeOffset + baseTime - newBaseTime			
        end
        -- baseTime = newBaseTime
        -- calculate current hour and min and set
        hour = math.floor(((baseTime+timeOffset)/60)%24)
        minute = math.floor((baseTime+timeOffset)%60)
        NetworkOverrideClockTime(hour, minute, 0)
    end
end)
2 Likes

It’s working thank you for help :slight_smile:

thank you bro!

1 Like

Hi guys, How did you get your time to update like

12:01 , 12:02 , 12:03 …

mine jumps from random times and takes a random amount of time do go from one time to the other. How do i change this?
QBCore Framework
Using qb-weathersync
I do have the vSyncR installed

EDIT: install Renewed-weathersync
its the best thing i have ever done!