Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add isNight and change some requires to lib.load #16

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compatability/qb/server.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Config = require 'config.weather'
local Config = lib.load('config.weather')

local globalState = GlobalState

Expand All @@ -9,11 +9,11 @@ local function exportHandler(exportName, func)
end

exportHandler('nextWeatherStage', function()
return print("RENEWED WEATHERSYNC - THIS EXPORT IS NOT SUPPORTED")
return print("RENEWED WEATHERSYNC - THIS EXPORT IS NOT SUPPORTED (nextWeatherStage)")
end)

exportHandler('setDynamicWeather', function()
return print("RENEWED WEATHERSYNC - THIS EXPORT IS NOT SUPPORTED")
return print("RENEWED WEATHERSYNC - THIS EXPORT IS NOT SUPPORTED (setDynamicWeather)")
end)


Expand Down
2 changes: 1 addition & 1 deletion config/time.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
return {
timeScale = 4000, -- How many milliseconds per minute in GTA time (2000ms is normal for a 48 minute day)

useNightScale = true, -- If true, the server will use timeScaleNight to alter the time during night
useNightScale = false, -- If true, the server will use timeScaleNight to alter the time during night
timeScaleNight = 8000, -- How many milliseconds per minute in GTA time DURING NIGHT

nightTime = {
Expand Down
8 changes: 6 additions & 2 deletions server/time.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Config = require 'config.time'
local Config = lib.load('config.time')

local globalState = GlobalState

Expand All @@ -16,7 +16,7 @@ local hour = startTime.hour
-- Syncs the GlobalStates (does not replicate if the values are the same)
globalState.timeScale = currentScale
globalState.freezeTime = freezeTime

globalState.isNight = hour >= Config.nightTime.beginning or hour < Config.nightTime.ending

-- Loop that syncs the minute and hours of the servers to clients.
CreateThread(function()
Expand All @@ -43,6 +43,7 @@ end)

local nightScale = Config.timeScaleNight
local nightStart, nightEnd = Config.nightTime.beginning, Config.nightTime.ending

AddStateBagChangeHandler('currentTime', 'global', function(_, _, value)
if value then
hour = value.hour
Expand All @@ -58,6 +59,9 @@ AddStateBagChangeHandler('currentTime', 'global', function(_, _, value)
end
end
end

globalState.isNight = hour >= Config.nightTime.beginning or hour < Config.nightTime.ending

end)

AddStateBagChangeHandler('timeScale', 'global', function(_, _, value)
Expand Down
2 changes: 1 addition & 1 deletion server/weather.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local buildWeatherList = require 'server.weatherbuilder'

local useScheduledWeather = require 'config.weather'.useScheduledWeather
local useScheduledWeather = lib.load('config.weather').useScheduledWeather
local weatherList = buildWeatherList()

local overrideWeather = false
Expand Down
4 changes: 2 additions & 2 deletions server/weatherbuilder.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Config = require 'config.weather'
local Config = lib.load('config.weather')

local currentMonth = tonumber(os.date('%m'))

Expand Down Expand Up @@ -68,7 +68,7 @@ local function isWeatherEventAllowed(chance, hasRain, minutesSinceRain, timeBefo
for i = weatherAmount - 5, weatherAmount do
if weatherList[i].weather == weather then
count += 1

if count > 1 then
return false
end
Expand Down
Loading