Untitled diff

Created Diff never expires
5 removals
93 lines
1 addition
89 lines
CurrentWeather = 'EXTRASUNNY'
local lastWeather = CurrentWeather
local baseTime = 0
local timeOffset = 0
local timer = 0
local freezeTime = false
local freezeTime = false
local blackout = false
local blackout = false


RegisterNetEvent('vSync:updateWeather')
RegisterNetEvent('vSync:updateWeather')
AddEventHandler('vSync:updateWeather', function(NewWeather, newblackout)
AddEventHandler('vSync:updateWeather', function(NewWeather, newblackout)
CurrentWeather = NewWeather
CurrentWeather = NewWeather
blackout = newblackout
blackout = newblackout
end)
end)


Citizen.CreateThread(function()
Citizen.CreateThread(function()
while true do
while true do
if lastWeather ~= CurrentWeather then
if lastWeather ~= CurrentWeather then
lastWeather = CurrentWeather
lastWeather = CurrentWeather
SetWeatherTypeOverTime(CurrentWeather, 15.0)
SetWeatherTypeOverTime(CurrentWeather, 15.0)
Citizen.Wait(15000)
Citizen.Wait(15000)
end
end
Citizen.Wait(100) -- Wait 0 seconds to prevent crashing.
Citizen.Wait(100) -- Wait 0 seconds to prevent crashing.
SetBlackout(blackout)
SetBlackout(blackout)
ClearOverrideWeather()
ClearOverrideWeather()
ClearWeatherTypePersist()
ClearWeatherTypePersist()
SetWeatherTypePersist(lastWeather)
SetWeatherTypePersist(lastWeather)
SetWeatherTypeNow(lastWeather)
SetWeatherTypeNow(lastWeather)
SetWeatherTypeNowPersist(lastWeather)
SetWeatherTypeNowPersist(lastWeather)
if lastWeather == 'XMAS' then
if lastWeather == 'XMAS' then
SetForceVehicleTrails(true)
SetForceVehicleTrails(true)
SetForcePedFootstepsTracks(true)
SetForcePedFootstepsTracks(true)
else
else
SetForceVehicleTrails(false)
SetForceVehicleTrails(false)
SetForcePedFootstepsTracks(false)
SetForcePedFootstepsTracks(false)
end
end
end
end
end)
end)


RegisterNetEvent('vSync:updateTime')
RegisterNetEvent('vSync:updateTime')
AddEventHandler('vSync:updateTime', function(base, offset, freeze)
AddEventHandler('vSync:updateTime', function(base, offset, freeze)
freezeTime = freeze
freezeTime = freeze
timeOffset = offset
timeOffset = offset
baseTime = base
baseTime = base
end)
end)


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


AddEventHandler('playerSpawned', function()
AddEventHandler('playerSpawned', function()
TriggerServerEvent('vSync:requestSync')
TriggerServerEvent('vSync:requestSync')
end)
end)


Citizen.CreateThread(function()
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/weather', 'Change the weather.', {{ name="weatherType", help="Available types: extrasunny, clear, neutral, smog, foggy, overcast, clouds, clearing, rain, thunder, snow, blizzard, snowlight, xmas & halloween"}})
TriggerEvent('chat:addSuggestion', '/weather', 'Change the weather.', {{ name="weatherType", help="Available types: extrasunny, clear, neutral, smog, foggy, overcast, clouds, clearing, rain, thunder, snow, blizzard, snowlight, xmas & halloween"}})
TriggerEvent('chat:addSuggestion', '/time', 'Change the time.', {{ name="hours", help="A number between 0 - 23"}, { name="minutes", help="A number between 0 - 59"}})
TriggerEvent('chat:addSuggestion', '/time', 'Change the time.', {{ name="hours", help="A number between 0 - 23"}, { name="minutes", help="A number between 0 - 59"}})
TriggerEvent('chat:addSuggestion', '/freezetime', 'Freeze / unfreeze time.')
TriggerEvent('chat:addSuggestion', '/freezetime', 'Freeze / unfreeze time.')
TriggerEvent('chat:addSuggestion', '/freezeweather', 'Enable/disable dynamic weather changes.')
TriggerEvent('chat:addSuggestion', '/freezeweather', 'Enable/disable dynamic weather changes.')
TriggerEvent('chat:addSuggestion', '/morning', 'Set the time to 09:00')
TriggerEvent('chat:addSuggestion', '/morning', 'Set the time to 09:00')
TriggerEvent('chat:addSuggestion', '/noon', 'Set the time to 12:00')
TriggerEvent('chat:addSuggestion', '/noon', 'Set the time to 12:00')
TriggerEvent('chat:addSuggestion', '/evening', 'Set the time to 18:00')
TriggerEvent('chat:addSuggestion', '/evening', 'Set the time to 18:00')
TriggerEvent('chat:addSuggestion', '/night', 'Set the time to 23:00')
TriggerEvent('chat:addSuggestion', '/night', 'Set the time to 23:00')
TriggerEvent('chat:addSuggestion', '/blackout', 'Toggle blackout mode.')
TriggerEvent('chat:addSuggestion', '/blackout', 'Toggle blackout mode.')
end)
end)


-- Display a notification above the minimap.
-- Display a notification above the minimap.
function ShowNotification(text, blink)
function ShowNotification(text, blink)
if blink == nil then blink = false end
if blink == nil then blink = false end
SetNotificationTextEntry("STRING")
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName(text)
AddTextComponentSubstringPlayerName(text)
DrawNotification(blink, false)
DrawNotification(blink, false)
end
end


RegisterNetEvent('vSync:notify')
RegisterNetEvent('vSync:notify')
AddEventHandler('vSync:notify', function(message, blink)
AddEventHandler('vSync:notify', function(message, blink)
ShowNotification(message, blink)
ShowNotification(message, blink)
end)
end)