NX CreativeNX CreativeDocs
Scriptsnx_fourseasons

Events

Events and shared state your resources can listen to, trigger, or read.

Only events that form a stable integration surface are listed here. Internal sync events (request/response handshakes, pending replay, admin control relays) are intentionally undocumented and subject to change.

Event names are centralized in shared/constants.lua on the NxFS_Constants.Events table. The literal strings below match that table and are safe to hard-code.

Client events (listen)

These fire on the client. Use AddEventHandler in any client script.

nx_fourseasons:weatherChanged

Fired when the active weather type or intensity changes meaningfully (type change, or intensity delta greater than 0.3).

AddEventHandler('nx_fourseasons:weatherChanged', function(data)
    -- data.type        : new weather type (e.g. 'RAIN', 'THUNDER')
    -- data.intensity   : new intensity (0.0 to 1.0)
    -- data.oldType     : previous weather type
    -- data.oldIntensity: previous intensity
    print(data.oldType, '->', data.type)
end)

nx_fourseasons:temperatureChanged

Fired whenever temperature updates on this client.

AddEventHandler('nx_fourseasons:temperatureChanged', function(newTemp, oldTemp)
    print(('Temp: %d -> %d'):format(oldTemp or newTemp, newTemp))
end)

nx_fourseasons:timeUpdated

Fired after a time sync from the server. Carries the same shape as GetCurrentTime().

AddEventHandler('nx_fourseasons:timeUpdated', function(time)
    -- time.hour, time.minute, time.second, time.day, time.month, time.year
    -- time.useRealTime, time.freeze
end)

Net events (server to client)

These are network events broadcast by the server. Use RegisterNetEvent plus AddEventHandler on the client.

nx_fourseasons:weatherUpdated

Broadcast when the server rolls a new weather state or when a force-sync fires.

RegisterNetEvent('nx_fourseasons:weatherUpdated', function(weatherType, intensity)
    -- weatherType: string, intensity: number 0.0-1.0
end)

nx_fourseasons:seasonUpdated

Broadcast when the season transitions.

RegisterNetEvent('nx_fourseasons:seasonUpdated', function(season)
    -- season: 'SPRING' | 'SUMMER' | 'FALL' | 'WINTER'
end)

nx_fourseasons:temperatureUpdated

Broadcast when the server-authoritative temperature changes.

RegisterNetEvent('nx_fourseasons:temperatureUpdated', function(temperature)
    -- temperature: number (Celsius)
end)

nx_fourseasons:receiveForecast

Sent on join, and on every forecast refresh.

RegisterNetEvent('nx_fourseasons:receiveForecast', function(forecast)
    -- forecast: array of { weather, temperature, intensity, day, date, stats }
end)

nx_fourseasons:stormStateUpdated

Broadcast on every Config.StormSystems.SyncIntervalSeconds tick while storm systems are active.

RegisterNetEvent('nx_fourseasons:stormStateUpdated', function(stormState)
    -- stormState: table describing blackout, strike, and ocean state
end)

nx_fourseasons:stormStrikeFx

Fired at the targeted client when a lightning strike FX should play nearby.

RegisterNetEvent('nx_fourseasons:stormStrikeFx', function(payload)
    -- payload: { origin, distance, intensity, ... }
end)

nx_fourseasons:seasonalEvent

Fired when a seasonal event starts (for example a spring thunderstorm or a falling-leaves event in fall).

RegisterNetEvent('nx_fourseasons:seasonalEvent', function(data)
    -- data.name        : event name
    -- data.season      : season the event belongs to
    -- data.notification: pre-formatted localized message (may be nil)
end)

Net events (client triggers)

nx_fourseasons:playerLoaded

Trigger this from your framework's player-loaded handler to force an initial sync for the joining player. The resource also listens for common framework events internally, so this is only needed if those hooks are not firing in your setup.

TriggerServerEvent('nx_fourseasons:playerLoaded')

Platform API events (server)

These fire on the server as local events. Listen with AddEventHandler in any server script. They are registered only when Config.API.Enabled is true, and each fires when the underlying field actually changes, so they are safe to treat as change notifications rather than a fixed tick.

nx_fourseasons:onWeatherChanged

Fired when weather, intensity, blackout, or snow depth changes. The payload is the same blob returned by the GetWeatherState export.

AddEventHandler('nx_fourseasons:onWeatherChanged', function(state)
    -- state.weather, state.intensity, state.temperature, state.feelsLike
    -- state.isBlackout, state.snowDepth, state.storm, state.forecastStamp
end)

nx_fourseasons:onSeasonChanged

AddEventHandler('nx_fourseasons:onSeasonChanged', function(season)
    -- season: 'SPRING' | 'SUMMER' | 'FALL' | 'WINTER'
end)

nx_fourseasons:onTemperatureChanged

AddEventHandler('nx_fourseasons:onTemperatureChanged', function(temperature)
    -- temperature: number (Celsius)
end)

nx_fourseasons:onForecastUpdated

Fired once per daily forecast regeneration.

AddEventHandler('nx_fourseasons:onForecastUpdated', function(forecast)
    -- forecast: the full forecast array (each day carries a stats table)
end)

nx_fourseasons:onStormStateChanged

Fired when the storm signature (enabled, blackout, or ocean state) shifts.

AddEventHandler('nx_fourseasons:onStormStateChanged', function(stormState)
    -- stormState: table describing blackout, strike, and ocean state
end)

Exposure events (server)

nx_fourseasons:playerTemperatureDanger

Fired on the server whenever a player's exposure tier changes. Registered only when Config.Exposure.Enabled is true. Use it to react to hypothermia or heatstroke from another resource (medical scripts, HUDs, logging). The exposure system itself never drains health.

AddEventHandler('nx_fourseasons:playerTemperatureDanger', function(src, level, kind)
    -- src   : player server id
    -- level : 0 (comfortable) to 3 (severe)
    -- kind  : 'cold' | 'heat' | false
end)

Shared state (GlobalState and statebags)

For a poll or subscribe model that survives resource restarts, read these keys instead of listening for events. GlobalState keys are written only when Config.API.Enabled is true.

GlobalState.nxWeather

The weather state blob (same shape as the GetWeatherState export) plus a t timestamp. Rebuilt at most every Config.API.GlobalStateThrottleMs.

local state = GlobalState.nxWeather
if state then
    print(state.weather, state.feelsLike, state.isBlackout)
end

GlobalState.nxSnowDepth

Current tracked snow depth in metres. Written only when Config.SnowDepth.Enabled is true.

local depth = GlobalState.nxSnowDepth or 0.0

GlobalState.nxWeatherLockOwner

The resource name whose weather lock is currently applied, or false when no lock is active.

local owner = GlobalState.nxWeatherLockOwner

Player statebag nxExposure

Each player's body-temperature exposure, mirrored on their statebag. Readable from client or server.

-- Server
local e = Player(src).state.nxExposure
-- Client (another player's exposure by server id)
local e = Player(serverId).state.nxExposure
-- e = { level = 0..3, kind = 'cold' | 'heat' | false }
NX Docs