From ee4d4e362158deafd6224936e017cd980d9ba85f Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 25 Oct 2022 22:40:44 -0500 Subject: [PATCH] Chance of snow by month --- scripts/server/config.js | 1 + scripts/server/timers.js | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/server/config.js b/scripts/server/config.js index c3a1ed8e..6d03f89a 100644 --- a/scripts/server/config.js +++ b/scripts/server/config.js @@ -246,6 +246,7 @@ let globalConfig = { fishingCastMaxStrength: 100, fishingCastMinStrength: 30, jobRouteLocationSphereRadius: 3, + monthlyChanceOfSnow: [90, 50, 10, 0, 0, 0, 0, 0, 0, 0, 50, 90], }; // =========================================================================== diff --git a/scripts/server/timers.js b/scripts/server/timers.js index 904f0a23..c35d6327 100644 --- a/scripts/server/timers.js +++ b/scripts/server/timers.js @@ -133,8 +133,13 @@ function thirtyMinuteTimerFunction() { if (getClients().length > 0) { checkPayDays(); } - saveServerDataToDatabase(); + + if (isGameFeatureSupported("snow")) { + checkSnowChance(); + } + checkInactiveVehicleRespawns(); + saveServerDataToDatabase(); } // =========================================================================== @@ -262,7 +267,7 @@ function checkServerGameTime() { game.time.minute = getServerConfig().minute; } - updateTimeRule(); + updateServerRules(); } // =========================================================================== @@ -335,4 +340,15 @@ function checkInactiveVehicleRespawns() { } } +// =========================================================================== + +function checkSnowChance() { + let date = new Date(); + + let shouldBeSnowing = getRandomBoolWithProbability(getGlobalConfig().monthlyChanceOfSnow[date.getMonths()]); + getServerConfig().groundSnow = shouldBeSnowing; + getServerConfig().fallingSnow = shouldBeSnowing; + updatePlayerSnowState(null); +} + // =========================================================================== \ No newline at end of file