NX CreativeNX CreativeDocs
Scriptsnx_fourseasons

Exports

Public exports registered by nx_fourseasons. Client-side weather state plus the server-side Weather Platform API.

nx_fourseasons registers client exports for weather state, sync, road traction, and screen FX, plus server exports that form the Weather Platform API. Call client exports from any client script and server exports from any server script, both via exports.nx_fourseasons:<Name>().

The server exports are gated by Config.API.Enabled. The weather-control exports (RequestWeather, LockWeather, ReleaseWeather, GetWeatherControlOwner) also require Config.API.AllowControl.

State (client)

exports.nx_fourseasons:GetCurrentWeatherclient

Return the current weather snapshot for this client.

Returns

{ weather: string, type: string, intensity: number, temperature: number, season: string, storm: table | nil }
local w = exports.nx_fourseasons:GetCurrentWeather()
print(w.weather, w.intensity, w.temperature)
exports.nx_fourseasons:GetCurrentTemperatureclient

Return the current temperature in Celsius.

Returns

number
local temp = exports.nx_fourseasons:GetCurrentTemperature()
if temp < 0 then
    -- Player is in sub-zero conditions
end
exports.nx_fourseasons:GetCurrentSeasonclient

Return the active season id.

Returns

'SPRING' | 'SUMMER' | 'FALL' | 'WINTER'
local season = exports.nx_fourseasons:GetCurrentSeason()
exports.nx_fourseasons:GetCurrentTimeclient

Return the synced clock for this client.

Returns

{ hour: number, minute: number, second: number, day: number, month: number, year: number, useRealTime: boolean, freeze: boolean }
local t = exports.nx_fourseasons:GetCurrentTime()
print(('%02d:%02d'):format(t.hour, t.minute))
exports.nx_fourseasons:GetCurrentStormStateclient

Return the current storm state broadcast by the server. Nil if storms are disabled.

Returns

table | nil
local storm = exports.nx_fourseasons:GetCurrentStormState()
exports.nx_fourseasons:IsPlayerIndoorsclient

Return whether the player is currently detected as indoors. Uses a cached check so it is cheap to poll.

Returns

boolean
if exports.nx_fourseasons:IsPlayerIndoors() then
    -- Skip outdoor-only FX
end

Exposure (client)

exports.nx_fourseasons:GetExposureLevelclient

Return the local player's current body-temperature exposure. level is 0 (comfortable) to 3 (severe). kind is the direction of the danger, or false when comfortable. Available only while Config.Exposure.Enabled is true.

Returns

{ level: number, kind: 'cold' | 'heat' | false }
local e = exports.nx_fourseasons:GetExposureLevel()
if e.level >= 2 and e.kind == 'cold' then
    -- Player is in cold danger
end

Forecast (client)

exports.nx_fourseasons:GetForecastclient

Return the server-provided forecast. With no argument, returns the full forecast array. With a day offset, returns that single day.

Parameters

  • daysAhead?number0 for today, 1 for tomorrow, up to Config.Forecast.Days - 1.

Returns

table[] | { weather: string, type: string, temperature: number, intensity: number, day?: number, date?: any }
-- Full forecast
local days = exports.nx_fourseasons:GetForecast()

-- Single day
local tomorrow = exports.nx_fourseasons:GetForecast(1)
print(tomorrow.weather, tomorrow.temperature)

Sync control (client)

Pause or resume the weather and time sync for the local player. Useful for cutscenes, interiors, and minigames that run in an isolated environment.

exports.nx_fourseasons:PauseSyncclient

Pause or resume weather and time sync on this client. Pending updates are replayed on resume.

Parameters

  • pausedbooleantrue to pause, false to resume.

Returns

boolean
-- Freeze weather during a cutscene
exports.nx_fourseasons:PauseSync(true)

-- Resume after
exports.nx_fourseasons:PauseSync(false)
exports.nx_fourseasons:RequestSyncclient

Ask the server to resend the full weather, forecast, and storm state to this client.

Returns

true
exports.nx_fourseasons:RequestSync()
exports.nx_fourseasons:IsSyncPausedclient

Return whether sync is currently paused on this client.

Returns

boolean
if exports.nx_fourseasons:IsSyncPaused() then
    exports.nx_fourseasons:PauseSync(false)
end

Road traction (client)

Override traction reductions on individual vehicles. Useful for scripted missions where a vehicle should ignore the active weather, or for adding a stronger penalty to a specific vehicle class.

exports.nx_fourseasons:ToggleCurrentRoadEffectsclient

Enable or disable the active weather-driven road effect on a vehicle.

Parameters

  • vehiclenumberVehicle entity handle.
  • enabledbooleantrue to apply, false to suspend.
local veh = GetVehiclePedIsIn(PlayerPedId(), false)
exports.nx_fourseasons:ToggleCurrentRoadEffects(veh, false)
exports.nx_fourseasons:SetVehicleRoadEffectclient

Override the traction reduction applied to a vehicle. Value replaces the active weather default.

Parameters

  • vehiclenumber
  • overrideReductionnumberTraction reduction in the range 0.0 (none) to 1.0 (max).
exports.nx_fourseasons:SetVehicleRoadEffect(veh, 0.5)
exports.nx_fourseasons:GetVehicleRoadEffectclient

Return the road-effect state currently tracked for a vehicle.

Parameters

  • vehiclenumber

Returns

table | nil
exports.nx_fourseasons:ResetVehicleRoadEffectclient

Clear any override set by SetVehicleRoadEffect and reapply the active weather default.

Parameters

  • vehiclenumber

Screen weather FX (client)

Toggle the screen-space rain drops and the global weather screen overlay per-player. Preferences are kept on the client.

exports.nx_fourseasons:SetRainScreenDropsEnabledclient

Enable or disable screen-space rain drops.

Parameters

  • enabledboolean

Returns

boolean
exports.nx_fourseasons:IsRainScreenDropsEnabledclient

Returns

boolean
exports.nx_fourseasons:ToggleRainScreenDropsclient

Toggle screen-space rain drops and return the new state.

Returns

boolean
exports.nx_fourseasons:SetScreenWeatherEnabledclient

Enable or disable the full screen weather overlay (umbrella of screen-space FX driven by the active weather).

Parameters

  • enabledboolean

Returns

boolean
exports.nx_fourseasons:IsScreenWeatherEnabledclient

Returns

boolean
exports.nx_fourseasons:ToggleScreenWeatherclient

Toggle the full screen weather overlay and return the new state.

Returns

boolean

Weather Platform API: read (server)

Server-side reads of the authoritative weather state. Registered only when Config.API.Enabled is true. For a push model, read the nxWeather and nxSnowDepth GlobalState keys or listen for the on* events on the Events page.

exports.nx_fourseasons:GetWeatherserver

Return the current weather type. Nil before the first sync.

Returns

string | nil
local weather = exports.nx_fourseasons:GetWeather()
exports.nx_fourseasons:GetSeasonserver

Return the active season id.

Returns

'SPRING' | 'SUMMER' | 'FALL' | 'WINTER' | nil
exports.nx_fourseasons:GetTemperatureserver

Return the current ambient temperature in Celsius.

Returns

number | nil
exports.nx_fourseasons:GetWeatherStateserver

Return the merged weather state blob. This is the same shape published on GlobalState.nxWeather and passed to the onWeatherChanged event.

Returns

{ weather: string, intensity: number, season: string, temperature: number, feelsLike: number, isBlackout: boolean, snowDepth: number, storm: table, forecastStamp: any }
local s = exports.nx_fourseasons:GetWeatherState()
print(s.weather, s.feelsLike, s.snowDepth, s.isBlackout)
exports.nx_fourseasons:GetStormStateserver

Return the current storm state (blackout, strike, and ocean fields). Nil if storms are disabled.

Returns

table | nil
exports.nx_fourseasons:GetForecastserver

Return the full server forecast array. Each entry carries a nested stats table with humidity, wind, UV, dew point, and feels-like.

Returns

table[]
exports.nx_fourseasons:GetIntradaySlotsserver

Return today's intraday prediction slots (the timeline that betting settles against). Nil if the forecast is not ready.

Returns

table | nil
exports.nx_fourseasons:IsBlackoutserver

Return whether a storm blackout pulse is currently active.

Returns

boolean
exports.nx_fourseasons:GetSnowDepthserver

Return the current tracked snow depth in metres. Also published on GlobalState.nxSnowDepth.

Returns

number
exports.nx_fourseasons:GetPlayerExposureserver

Return a player's body-temperature exposure. Also mirrored on the player statebag nxExposure. Returns level 0 with kind false when exposure is disabled or the player has no record.

Parameters

  • srcnumberPlayer server id.

Returns

{ level: number, kind: 'cold' | 'heat' | false }
local e = exports.nx_fourseasons:GetPlayerExposure(source)
if e.level >= 2 then
    -- Player is in a danger tier
end

Weather control (server)

Request or lock the weather from another resource. Registered only when both Config.API.Enabled and Config.API.AllowControl are true. Every lock is attributed to the invoking resource and auto-reverts when that resource stops. Higher priority wins; the applied owner is published on GlobalState.nxWeatherLockOwner.

exports.nx_fourseasons:RequestWeatherserver

Request a weather type at default priority 10. Returns a token, or false if control is disabled or the caller is unattributable. Auto-expires after opts.durationMs when provided.

Parameters

  • weatherTypestringA GTA weather type, e.g. 'THUNDER' or 'SNOW'.
  • opts?table{ intensity?: number (0.0-1.0), durationMs?: number, priority?: number }. Intensity is snapshotted at register time; omit to reuse the current value.

Returns

string | false
-- Ask for thunder for 10 minutes
local token = exports.nx_fourseasons:RequestWeather('THUNDER', { durationMs = 600000 })
exports.nx_fourseasons:LockWeatherserver

Lock a weather type at default priority 100. A lock never auto-expires: any durationMs is ignored. Returns a token, or false if control is disabled or the caller is unattributable.

Parameters

  • weatherTypestring
  • opts?table{ intensity?: number (0.0-1.0), priority?: number }.

Returns

string | false
local token = exports.nx_fourseasons:LockWeather('EXTRASUNNY')
-- ... later
exports.nx_fourseasons:ReleaseWeather(token)
exports.nx_fourseasons:ReleaseWeatherserver

Release the calling resource's lock. The token must match the lock owned by the invoking resource. A nil token releases the caller's own lock unconditionally. Returns true when a lock was released.

Parameters

  • token?stringThe token returned by RequestWeather or LockWeather.

Returns

boolean
exports.nx_fourseasons:GetWeatherControlOwnerserver

Return the resource name whose lock is currently applied, or nil when no lock is active.

Returns

string | nil
NX Docs