All resources

rsg-weather – Developer Docs#

Flow#

Server (server/server.lua) owns weather/time/wind and publishes GlobalState.rsgWeather, rsgTime, rsgWind. Each client (client/client.lua) reads them, translates weather per region (translateWeather) and applies it.

Applying weather (client)#

applyWeather calls CLEAR_OVERRIDE_WEATHER (0x80A398F16FFE3CC3) then _SET_WEATHER_TYPE (0x59174F1AFE095B5A, hash, true, true, true, transition, false). It also calls _SET_RAIN (0x193DFC0526830FD6) with -1.0 so a rain level forced by another script (e.g. 0.0 during character select) can't block rain. Clearing first stops overrides left by other scripts from blocking the change.

Debugging#

/weatherdebug – prints sync | server | applied | local | region | x y | temp and forces a re-apply.

  • sync=false: client sync is off (/myweather, /mytime, sync toggle, or a legacy weathersync:* event from another resource).
  • server ≠ region: regional translation changed it (snow north, desert variants).

Other resources#

Resources should change weather via exports['rsg-weather']:setWeather(type, transition, freeze, permanentSnow) / setTime / setWind, never by calling the weather natives directly. rsg-adminmenu does this when rsg-weather is started.

<!-- BEGIN AUTO-REFERENCE (generated from the code; re-run the generator instead of editing by hand) -->

Technical reference#

Generated from the source of rsg-weather 3.1.3. Names, arguments and defaults below are read straight from the code.

Dependencies#

rsg-core, oxmysql

Database#

Tables: rsg_weather_state.

Tables are created automatically on start while Config.AutoDatabase = true (default). Nothing is ever dropped or overwritten. For a manual install set Config.AutoDatabase = false and import installation/rsg-weather.sql once.

-- shared/config.lua
Config.AutoDatabase = true -- false = import the SQL file yourself

Configuration#

OptionDefaultNotes
Config.AutoDatabasetruebuild the database tables automatically on start (set false and import the SQL file for a manual install)
Config.Debugfalse
Config.AdminPermissions{ 'god', 'admin' }RSGCore permission levels allowed to use admin commands / menu
Config.SyncDelay5000ms between server -> client syncs
Config.EnableLegacyNetEventstrueaccept old weathersync:* net events from clients (admin-checked)
Config.TimeDHMSToTime(0, 6, 0, 0)seconds of a week (0-604799) or DHMSToTime(day, hour, minute, second), day 0 = Sunday
Config.Timescale4in-game seconds per real second (30 = vanilla). 0 = use real server clock
Config.RealTimeOffset0seconds, only used when Timescale = 0
Config.TimeIsFrozenfalse
Config.Weather'sunny'
Config.WeatherIntervalDHMSToTime(0, 1, 0, 0)in-game time between changes
Config.WeatherIsFrozenfalse
Config.PermanentSnowfalse
Config.DynamicSnowtruesnow on ground in snowy regions / snowy weather
Config.MaxForecast23number of intervals queued (23 = 24h forecast)
Config.RegionalWeathertruetranslate weather per region (snow in north, sandstorm in desert...)
Config.WindDirection0.0
Config.WindSpeed0.0
Config.WindIsFrozenfalse
Config.WindShearDirection45degrees per interval of altitude
Config.WindShearSpeed2.0speed added per interval of height above ground
Config.WindShearInterval50.0metres
Config.MeanSeaLevel40.0
Config.WeatherPatterntable
Config.isRDRtrue
Config.weatherTypesWeatherTypes
Config.weatherPatternConfig.WeatherPattern
Config.timescaleConfig.Timescale
Config.syncDelayConfig.SyncDelay
Config.Seasonaltable
Config.Enabledtrue
Config.CheckInterval60
Config.Eventstabledate ranges are inclusive and may wrap the year (e.g. Dec 28 -> Jan 2)

Exports#

Server

ExportArgumentsFile
getActivePatternName``server/patterns.lua
getSavedPatterns``server/patterns.lua
getSeason``server/seasonal.lua
setSeasonMode``server/seasonal.lua

Client

ExportArgumentsFile
toggleSync``client/client.lua
setSyncEnabled``client/client.lua
isSyncEnabled``client/client.lua
setMyWeather``client/client.lua
setMyTime``client/client.lua
isSnowOnGround``client/client.lua
getWeather``client/client.lua
getServerWeather``client/client.lua
getWindDirection``client/client.lua
toggleForecast``client/menu.lua
isForecastOpen``client/menu.lua
getSeason``client/seasonal.lua
isBloodMoon``client/seasonal.lua
-- example
local result = exports['rsg-weather']:getActivePatternName()

Callbacks#

CallbackSideArgumentsFile
rsg-weather:server:getPatternsserversrc, cbserver/patterns.lua
rsg-weather:server:savePatternserversrc, cb, name, pattern, applyserver/patterns.lua
rsg-weather:server:deletePatternserversrc, cb, nameserver/patterns.lua
rsg-weather:server:applyPatternserversrc, cb, nameserver/patterns.lua
rsg-weather:server:getForecastserversrc, cbserver/server.lua
rsg-weather:server:getAdminStateserversrc, cbserver/server.lua
rsg-weather:server:adminActionserversrc, cb, action, dataserver/server.lua
-- client side
RSGCore.Functions.TriggerCallback('rsg-weather:server:getPatterns', function(result)
    -- use result
end)

Events#

Server events can be fired by any client, so every handler re-validates the player, the arguments and any permission, distance or cooldown on the server. Never add a reward to a handler without those checks.

EventSideArgumentsFile
rsg-weather:client:toggleSyncclient``client/client.lua
rsg-weather:client:setMyTimeclient``client/client.lua
rsg-weather:client:setMyWeatherclient``client/client.lua
weathersync:toggleSyncclient``client/legacy.lua
weathersync:setSyncEnabledclient``client/legacy.lua
weathersync:setMyWeatherclient``client/legacy.lua
weathersync:setMyTimeclient``client/legacy.lua
weathersync:toggleForecastclient``client/legacy.lua
weathersync:openAdminUiclient``client/legacy.lua
rsg-weather:client:showForecastclient``client/menu.lua
rsg-weather:client:openAdminMenuclient``client/menu.lua
rsg-weather:client:bloodmoonDebugclient``client/seasonal.lua
weathersync:initserver``server/legacy.lua
weathersync:requestUpdatedForecastserver``server/legacy.lua
weathersync:requestUpdatedAdminUiserver``server/legacy.lua
-- from a client script
TriggerServerEvent('weathersync:init')
-- from a server script
TriggerClientEvent('rsg-weather:client:toggleSync', source)

Commands#

CommandNotesFile
/weatherdebugclient/client.lua
/forecastlocale('cmd_forecast')server/commands.lua

Locales#

Language files in locales/: de, el, en, es, fr, ja, nl, pl, pt-br, ro, ru. Set the language with setr rsg:locale "en".

<!-- END AUTO-REFERENCE -->