Upload files to "server"

This commit is contained in:
tanthius 2026-02-12 04:23:53 +00:00
parent 84526ca6da
commit 046f3fbdb8
2 changed files with 60 additions and 0 deletions

27
server/time.lua Normal file
View File

@ -0,0 +1,27 @@
print("^2[time]^7 Server time sync loaded")
-- CONFIG
local DAY_LENGTH_MINUTES = 48 -- GTA full day length (48 = vanilla-ish)
local START_HOUR = 12 -- initial time on server start
local currentMinute = START_HOUR * 60
CreateThread(function()
while true do
-- advance time
currentMinute = currentMinute + (1440 / (DAY_LENGTH_MINUTES * 60))
if currentMinute >= 1440 then currentMinute = 0 end
local hour = math.floor(currentMinute / 60)
local minute = math.floor(currentMinute % 60)
TriggerClientEvent("time:sync", -1, hour, minute)
Wait(1000)
end
end)
AddEventHandler("playerJoining", function()
local hour = math.floor(currentMinute / 60)
local minute = math.floor(currentMinute % 60)
TriggerClientEvent("time:sync", source, hour, minute)
end)

33
server/weather.lua Normal file
View File

@ -0,0 +1,33 @@
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)