- Add a common in-process event bus - Emit task lifecycle events from task store and instances - Register CAD listeners to invalidate task state
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.
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]];