-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathss_cli_weather.lua
86 lines (75 loc) · 3.34 KB
/
ss_cli_weather.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
83
84
85
86
local currentWeather = ss_default_weather
local transistioning = false
AddEventHandler( "onClientMapStart", function()
-- We just joined - so get the current weather.
TriggerServerEvent( "changeWeather",true )
TriggerServerEvent( "addWeatherChatSuggests" )
end)
RegisterNetEvent("changeWeather")
AddEventHandler("changeWeather", function(newWeather,blackout,startup)
transistioning = false
if newWeather ~= currentWeather then
--Set Weather (if first joining, we do this immediately, else we do it over 1 minute transition)
if startup then
--TraceMsg("StartUp Weather: " ..newWeather.. "\n",true)
--TraceMsg("StartUp Wind Value: "..tostring(ss_wind_speed_Mult[newWeather] + 0.10).. "\n",true)
SetWeatherTypeOverTime(newWeather, 1.00)
else
--TraceMsg("Change Weather: " ..newWeather.. "\n",true)
--TraceMsg("Change Wind Value: " ..tostring(ss_wind_speed_Mult[newWeather] + 0.10).. "\n",true)
SetWeatherTypeOverTime(newWeather, (ss_weather_timer*60/8) + 0.1)
transistioning = true
--TraceMsg("Weather in transistion ["..currentWeather.."]->["..newWeather.."] for "..tostring((ss_weather_timer*60/8) + 0.1).." seconds.",true)
Citizen.Wait(ss_weather_timer*60/8*1000)
end
Citizen.Wait(100)
currentWeather = newWeather
transistioning = false
--TraceMsg("Weather is ending transistion. ["..currentWeather.."]->["..newWeather.."]",true)
end
if currentWeather == 'XMAS' then
SetForceVehicleTrails(true)
SetForcePedFootstepsTracks(true)
else
SetForceVehicleTrails(false)
SetForcePedFootstepsTracks(false)
end
--Currently in a blackout?
SetBlackout(blackout)
--Set Starting Wind
SetWindDirection(32.1)
SetWind(ss_wind_speed_Mult[newWeather] + 0.1 )
SetWindSpeed(ss_wind_speed_Mult[newWeather] + 0.1)
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000) -- one second = 10 second switches
if transistioning == false then
ClearOverrideWeather()
ClearWeatherTypePersist()
SetWeatherTypePersist(currentWeather)
SetWeatherTypeNow(currentWeather)
SetWeatherTypeNowPersist(currentWeather)
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(30000) -- every 30 seconds
if transistioning == false and IsPedInAnyVehicle(GetPlayerPed(-1), false) then
if string.upper(currentWeather) == string.upper("THUNDER") or string.upper(currentWeather) == string.upper("CLEARING") then
local veh = GetVehiclePedIsIn( GetPlayerPed( -1 ) )
local curDirt = GetVehicleDirtLevel( veh , false)
if curDirt - 1 < 0 then
SetVehicleDirtLevel(veh, 0)
else
SetVehicleDirtLevel(veh, curDirt - 1.0)
end
end
end
end
end)
RegisterNetEvent("addWeatherChatSuggests")
AddEventHandler("addWeatherChatSuggests", function(newWeather,blackout,startup)
TriggerEvent('chat:addSuggestion', '/weather', 'Change the weather.', {{ name="weatherType", help="Available types: extrasunny, clear, neutral, smog, overcast, clouds, clearing, rain, thunder, snow, blizzard, snowlight, xmas"}})
end)