34 lines
745 B
Lua
34 lines
745 B
Lua
print("^2[weather]^7 Server weather sync loaded")
|
|
|
|
-- CONFIG
|
|
local WEATHER_TYPES = {
|
|
"CLEAR",
|
|
"EXTRASUNNY",
|
|
"CLOUDS",
|
|
"SMOG"
|
|
-- add RAIN / THUNDER if you want chaos 😈
|
|
}
|
|
|
|
local WEATHER_CHANGE_MINUTES = 30
|
|
|
|
local currentWeather = WEATHER_TYPES[1]
|
|
|
|
local function setWeather()
|
|
currentWeather = WEATHER_TYPES[math.random(#WEATHER_TYPES)]
|
|
TriggerClientEvent("weather:sync", -1, currentWeather)
|
|
end
|
|
|
|
CreateThread(function()
|
|
math.randomseed(os.time())
|
|
setWeather()
|
|
|
|
while true do
|
|
Wait(WEATHER_CHANGE_MINUTES * 60 * 1000)
|
|
setWeather()
|
|
end
|
|
end)
|
|
|
|
AddEventHandler("playerJoining", function()
|
|
TriggerClientEvent("weather:sync", source, currentWeather)
|
|
end)
|