WEATHER AND TIME INTEGRATION — RF CITYMAP 0.4.0
Standalone means CityMap does not require a framework or one particular weather
resource. Weather synchronization APIs differ. Built-in adapters cover the exact
interfaces below; custom adapters support other controllers with a local pause
mechanism. There is no universal FiveM export that pauses every third-party script.
Never substitute a server-wide weather command, stop a shared resource, or change
global weather just to capture a map. Normal players keep their synchronization.
1. CONFIGURATION
Edit resources/rf_citymap_capture/config.json while capture is idle. Inside
captureConditions use:
"captureConditions": {
"weather": "EXTRASUNNY",
"hour": 12,
"minute": 0,
"weatherBridge": {
"mode": "auto",
"providers": [],
"assumeSyncEnabled": false
}
}
This is a property inside the existing JSON object, not an additional whole file.
Keep fixedConditions=true to use the bridge. Restart ONLY rf_citymap_capture after
editing. Re-register companion adapters if the capture resource restarted.
auto: discover started qb-weathersync, night_natural_disasters and registered custom
controllers. Pause all discovered providers. Possible unknown controllers whose
names contain weather, vsync, timesync or time_sync stop capture with instructions.
Name detection is a warning aid: it cannot discover arbitrary controller names or
prove that every native-writing script is covered. Audit your installed controllers.
If none is found, capture refuses to guess; choose explicit or native mode.
explicit: declare every weather AND clock controller for the capturing client:
"weatherBridge": {
"mode": "explicit",
"providers": ["my_weather", "my_clock"],
"assumeSyncEnabled": false
}
Every listed controller must be started and have a built-in or custom adapter.
An explicit list does not suppress unlisted controllers. Include them all. Resource
names must match exactly. Renamed QB/Nights resources require a custom adapter.
native: use only FiveM's local weather/time natives:
"weatherBridge": {"mode":"native","providers":[],"assumeSyncEnabled":false}
Choose this only when no external controller is writing weather/time on the capture
client, or your integration already suspends those writes. Native mode does not
magically prevent another script from overriding the client.
assumeSyncEnabled: stock QB and the existing Nights interface do not supply a
verified getter for their prior pause state. The default false avoids guessing.
For those built-ins, confirm the capture player has normal outdoor weather/time
sync enabled, then set this value to true. This is an operator assertion, not a
state query. Do not capture while another script has suspended sync for an interior,
character selection or private-time mode. A custom state-aware adapter is preferable
when that prerequisite cannot be guaranteed. An observed QB DisableSync state is
rejected even when this assertion is true.
fixedConditions=false skips the bridge and local fixed lighting. This deliberately
uses live conditions; it is not a compatibility fix for consistent map captures.
2. BUILT-IN INTERFACES
qb-weathersync:
local TriggerEvent('qb-weathersync:client:DisableSync') to pause;
local TriggerEvent('qb-weathersync:client:EnableSync') to restore normal sync.
Both control the capturing client. The upstream EnableSync handler requests that
client's current state from the server; CityMap does not broadcast weather changes.
CityMap waits 16 seconds before processing its first cell because stock QB can
already be inside a 15-second weather-transition sleep when disabled.
CityMap observes those events after its own startup, not events from before it
loaded. Stock QB's private disable flag has no public getter in the verified source.
Source: https://github.com/qbcore-framework/qb-weathersync/blob/main/client.lua
night_natural_disasters:
exports['night_natural_disasters']:PauseSynchronization(true/false)
This is the existing RF server integration. An edition without that client export
needs a custom adapter. It is optional and is not a framework dependency.
Qbox, ESX, vSync, Renewed, cd_easytime, other commercial weather resources and forks
are not assumed to expose either of those APIs. Select the adapter for the actual
weather controller, independently of the framework. For example, a server using
stock qb-weathersync can use that adapter regardless of which framework it uses.
3. CUSTOM ADAPTER FILE — NO ADDITIONAL RESOURCE NEEDED
Edit resources/rf_citymap_capture/weather_custom.lua. RFWeatherAdapters is keyed by
the actual controller resource name. A custom definition also overrides a built-in.
This is an integration template: replace the marked functions with the actual
documented CLIENT API. The MyWeather functions below are placeholders, not exports
that CityMap supplies. Do not paste them unchanged and expect a controller to work.
RFWeatherAdapters = {
my_weather = {
pause = function(context)
local previous = MyWeather.getLocalSyncEnabled() -- REPLACE
-- Store previous state BEFORE the pause call, including on error.
MyWeather.savedForCityMap = previous -- REPLACE
MyWeather.setLocalSyncEnabled(false) -- REPLACE
return { enabled = previous }
end,
resume = function(token, context)
local previous = MyWeather.savedForCityMap -- REPLACE
if token then previous = token.enabled end
if previous ~= nil then
MyWeather.setLocalSyncEnabled(previous) -- REPLACE
end
MyWeather.savedForCityMap = nil -- REPLACE
end
}
}
Choose explicit mode with providers ["my_weather"], or let auto discover this
registered controller. Restart rf_citymap_capture after editing the Lua file.
These trusted callbacks run locally. No extra network event is required.
4. CLIENT EXPORTS — OPTIONAL COMPANION RESOURCE
exports['rf_citymap_capture']:RegisterWeatherAdapter(controllerName, hooks)
hooks.pause(context) returns an optional token. Returning false or throwing aborts
capture and triggers rollback, including the partially failing adapter.
hooks.resume(token, context) restores exactly the state acquired by pause.
context = { jobId=string, weather=string, hour=number, minute=number }.
Callbacks must be synchronous and must not Wait/yield or start asynchronous work
that changes synchronization later. Keep a recovery snapshot before changing state.
resume must tolerate a nil token after partial failure and must not enable sync
which was disabled before capture. A callback that needs delayed acknowledgement
requires an integration that makes its pause synchronous before returning.
exports['rf_citymap_capture']:UnregisterWeatherAdapter(controllerName)
Returns true only for a registration owned by the calling resource. Adapter
registration/replacement/unregistration is rejected while a weather lease is active.
Another resource cannot replace an adapter owned by a different resource.
exports['rf_citymap_capture']:IsCaptureWeatherActive()
Returns a local boolean. True while fixed capture owns the weather lease.
exports['rf_citymap_capture']:GetWeatherBridgeStatus()
Returns { active=boolean, providers={...}, registered={...},
qbState='unknown'|'enabled'|'disabled' }.
This is local status, not server-wide weather state or a universal state getter.
These exports are CLIENT exports, not server exports. They do not grant capture
permission; website authorization and rf.citymap.admin ACE are still required.
A companion resource needs this manifest:
fx_version 'cerulean'
game 'gta5'
dependency 'rf_citymap_capture'
dependency 'my_weather'
client_script 'client.lua'
In its client.lua, define hooks as above using your actual local controller API:
local function register()
if GetResourceState('rf_citymap_capture') == 'started' then
exports['rf_citymap_capture']:RegisterWeatherAdapter('my_weather', hooks)
end
end
AddEventHandler('onClientResourceStart', function(name)
if name == GetCurrentResourceName() or name == 'rf_citymap_capture' then
register()
end
end)
The hooks variable must be the {pause=...,resume=...} table you implemented. Start
this companion after capture and the controller. Registration is runtime-only:
re-register when capture restarts. A stopped companion's registrations are removed.
5. WEATHER SCRIPTS WITH NO PAUSE API
If you can edit the controller, make its local weather/time-writing code cooperate:
local function cityMapOwnsWeather()
if GetResourceState('rf_citymap_capture') ~= 'started' then return false end
local ok, active = pcall(function()
return exports['rf_citymap_capture']:IsCaptureWeatherActive()
end)
return ok and active
end
-- Inside the controller, guard BOTH weather and clock native writes:
if not cityMapOwnsWeather() then
-- existing local weather/time native calls go here
end
Guard every write path, including delayed transitions and event handlers; checking
only at the top of a loop before a long Wait is insufficient. Continue receiving
server sync updates so normal local synchronization resumes with the latest state.
Do not guard or pause the controller's server broadcast loop.
Register a cooperative adapter in weather_custom.lua for that controller:
RFWeatherAdapters = {
my_weather = {pause=function() return true end, resume=function() end}
}
The lease boolean itself suppresses the guarded local writes. After lease release
the controller must reapply its current normal local state. Implement that in its
loop/resume hook if it otherwise only writes when weather changes.
If the controller is encrypted and has neither a local pause API nor a supported
extension point, its author must expose one. CityMap cannot safely invent an API or
override uncooperative native writes reliably. Document that specific integration
requirement; do not claim untested automatic compatibility with every weather script.
6. CLEANUP, RESTARTS AND TESTING
All providers are validated before pausing any. A later pause failure rolls back
already acquired providers in reverse order, including the partial failure. Finish,
cancel, timeout, death, disconnect/resource shutdown paths attempt lease release.
Normal finish/cancel/timeout clears CityMap's local overrides and restores providers.
If an adapter throws during resume, other adapters and player restoration continue,
and F8 reports RESUME FAILED. Restore that controller's local synchronization before
another capture. If a controller/companion stops or a detected weather controller
starts during capture, capture aborts; verify its restart before trying again.
A hard game crash cannot execute Lua cleanup. Reconnect and confirm normal sync.
F8: mapweather (or /mapweather in game chat) prints local bridge status.
Run /mapupdate test, then a small /mapupdate area 100 capture. Test completion,
/mapupdate cancel, an intentional adapter failure, and restarting only the capture
resource. Check normal local weather/time returns and another player is unaffected.
Review the resulting images before building/approving/publishing a full map.
Changing captureConditions changes the lighting signature. Keep the old settings
for a legacy job you intend to resume/repair. The legacy weatherResource and
pauseWeatherSync shape is retained when weatherBridge is absent, including its old
native fallback; migrate to the explicit new bridge settings for new captures.
Never add weatherBridge to a partially captured job merely to bypass a mismatch.
Automated tests cover bridge selection, validation, rollback, tokens, local QB
events, resource lifecycle and prior observed QB state. Actual framework/controller
versions, in-game cleanup and visual lighting need acceptance testing before release.