- add EventBus-backed notification and sync requests with direct RPC fallback - centralize org notification/sync dispatch and reuse notification helpers - update economy, store, garage, locker, bank, and CAD flows to emit events
Forge Server Common
Overview
The common addon provides shared SQF utilities used by server-side Forge addons. It contains lightweight helpers only; gameplay domain state belongs in the specific domain addons or the Rust extension.
Dependencies
forge_server_main
Main Components
fnc_baseStore.sqfprovides shared hash-map object behavior such as JSON conversion.fnc_eventBus.sqfprovides a framework-wide in-process event bus for cross-addon notifications.fnc_log.sqfstandardizes server log messages.fnc_getPlayer.sqfresolves online players by UID.fnc_formatNumber.sqfformats numeric values for notifications and UI text.fnc_generateHash.sqfandfnc_generateSecureData.sqfprovide hashing and random data helpers.fnc_timeToSeconds.sqfconverts time values into seconds.
Notes
Keep this addon free of domain-specific behavior. If a helper needs actor, bank, org, task, store, or CAD state, it belongs in that addon instead.
Event Bus
The event bus is initialized as forge_server_common_EventBus during store
bootstrap. It is synchronous and in-process: listeners run immediately when an
event is emitted.
Event Naming
Use lower-case dot-separated names:
<domain>.<entity>.<action>for domain events, such ascad.assignment.assigned<domain>.<action>for simple lifecycle events, such astask.started
Prefer past-tense action names for events that report completed state changes:
created, started, assigned, acknowledged, declined, completed,
failed, cleared, updated, closed.
Payloads should be hash maps and should include stable identifiers first:
taskID, requestID, groupID, uid, orgID, or accountID as appropriate.
The event bus adds event, source, and timestamp when the event is emitted.
private _token = EGVAR(common,EventBus) call ["on", [
"task.completed",
{
params ["_event"];
["INFO", format ["Task completed: %1", _event getOrDefault ["taskID", ""]]] call EFUNC(common,log);
},
"example"
]];
EGVAR(common,EventBus) call ["emit", [
"task.completed",
createHashMapFromArray [["taskID", "task_001"]],
createHashMapFromArray [["source", "task"]]
]];
EGVAR(common,EventBus) call ["off", [_token]];