-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvs_client.lua
82 lines (75 loc) · 2.37 KB
/
vs_client.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
CurrentWeather = 'EXTRASUNNY'
local lastWeather = CurrentWeather
local baseTime = 0
local timeOffset = 0
local timer = 0
local freezeTime = false
local blackout = false
RegisterNetEvent('vSync:updateWeather')
AddEventHandler('vSync:updateWeather', function(NewWeather, newblackout)
CurrentWeather = NewWeather
blackout = newblackout
end)
Citizen.CreateThread(function()
while true do
if lastWeather ~= CurrentWeather then
lastWeather = CurrentWeather
SetWeatherTypeOverTime(CurrentWeather, 15.0)
Citizen.Wait(15000)
end
Citizen.Wait(1000) -- Wait 0 seconds to prevent crashing.
SetBlackout(blackout)
SetArtificialLightsState(blackout)
ClearOverrideWeather()
ClearWeatherTypePersist()
SetWeatherTypePersist(lastWeather)
SetWeatherTypeNow(lastWeather)
SetWeatherTypeNowPersist(lastWeather)
if lastWeather == 'XMAS' then
SetForceVehicleTrails(true)
SetForcePedFootstepsTracks(true)
else
SetForceVehicleTrails(false)
SetForcePedFootstepsTracks(false)
end
end
end)
RegisterNetEvent('vSync:updateTime')
AddEventHandler('vSync:updateTime', function(base, offset, freeze)
freezeTime = freeze
timeOffset = offset
baseTime = base
end)
Citizen.CreateThread(function()
local hour = 0
local minute = 0
while true do
Citizen.Wait(1000)
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)
AddEventHandler('playerSpawned', function()
TriggerServerEvent('vSync:requestSync')
end)
-- Display a notification above the minimap.
function ShowNotification(text, blink)
if blink == nil then blink = false end
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName(text)
DrawNotification(blink, false)
end
RegisterNetEvent('vSync:notify')
AddEventHandler('vSync:notify', function(message, blink)
ShowNotification(message, blink)
end)