Route sync and notifications through event bus

- 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
This commit is contained in:
Jacob Schmidt 2026-05-15 20:17:19 -05:00
parent c6a0982450
commit 27c3c5e502
11 changed files with 414 additions and 98 deletions

View File

@ -243,12 +243,24 @@ GVAR(BankBaseStore) = compileFinal createHashMapFromArray [
private _orgPatch = _orgResult getOrDefault ["patch", createHashMap];
if (_orgPatch isNotEqualTo createHashMap) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_orgPatch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_orgResult getOrDefault ["memberUids", []]);
private _memberUids = +(_orgResult getOrDefault ["memberUids", []]);
if (isNil QEGVAR(common,EventBus)) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_orgPatch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _memberUids;
} else {
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["memberUids", _memberUids],
["patch", +_orgPatch]
],
createHashMapFromArray [["source", "bank"]]
]];
};
};
if (_persistenceFailures isNotEqualTo []) then {

View File

@ -71,11 +71,24 @@ GVAR(CadStoreBaseClass) = compileFinal createHashMapFromArray [
];
if (_uid isEqualTo "" || { _message isEqualTo "" }) exitWith { false };
if (isNil QEGVAR(common,EventBus)) exitWith {
private _player = [_uid] call EFUNC(common,getPlayer);
if (_player isEqualTo objNull) exitWith { false };
private _player = [_uid] call EFUNC(common,getPlayer);
if (_player isEqualTo objNull) exitWith { false };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
true
};
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_uid]],
["notificationType", _type],
["title", _title],
["message", _message]
],
createHashMapFromArray [["source", "cad"]]
]];
true
}],
["resolveRequestPlayer", compileFinal {

View File

@ -5,3 +5,33 @@ PREP_RECOMPILE_START;
PREP_RECOMPILE_END;
// private _category = [QUOTE(MOD_NAME), LLSTRING(displayName)];
if (isNil QGVAR(EventBus)) then { call FUNC(eventBus); };
if (isNil QGVAR(NotificationEventTokens)) then {
private _sendNotification = {
params ["_event"];
private _uids = +(_event getOrDefault ["uids", []]);
private _type = _event getOrDefault ["notificationType", "info"];
private _title = _event getOrDefault ["title", ""];
private _message = _event getOrDefault ["message", ""];
private _duration = _event getOrDefault ["duration", -1];
if (_message isEqualTo "" || { _uids isEqualTo [] }) exitWith {};
private _params = [_type, _title, _message];
if (_duration >= 0) then {
_params pushBack _duration;
};
{
private _player = [_x] call FUNC(getPlayer);
if (isNull _player) then { continue; };
[CRPC(notifications,recieveNotification), _params, _player] call CFUNC(targetEvent);
} forEach _uids;
};
GVAR(NotificationEventTokens) = [
GVAR(EventBus) call ["on", ["notification.requested", _sendNotification, "common.notification.send"]]
];
};

View File

@ -4,7 +4,7 @@
* File: fnc_initFEconomyStore.sqf
* Author: IDSolutions
* Date: 2025-12-20
* Last Update: 2026-04-18
* Last Update: 2026-05-15
* Public: No
*
* Description:
@ -54,6 +54,30 @@ GVAR(FEconomyStore) = createHashMapObject [[
SETVAR(_target,liters,0);
true
}],
["notify", {
params [["_unit", objNull, [objNull]], ["_type", "info", [""]], ["_title", "Refueling", [""]], ["_message", "", [""]]];
if (isNull _unit || { _message isEqualTo "" }) exitWith { false };
private _uid = getPlayerUID _unit;
if (_uid isEqualTo "") exitWith { false };
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(notifications,recieveNotification), [_type, _title, _message], _unit] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_uid]],
["notificationType", _type],
["title", _title],
["message", _message]
],
createHashMapFromArray [["source", "economy"]]
]];
};
true
}],
["refuel", {
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
@ -62,13 +86,13 @@ GVAR(FEconomyStore) = createHashMapObject [[
private _currentFuel = fuel _target;
private _missingFuel = (1 - _currentFuel) max 0 min 1;
if (_missingFuel <= 0.001) exitWith {
[CRPC(notifications,recieveNotification), ["info", "Refueling", "Vehicle fuel tank is already full."], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "info", "Refueling", "Vehicle fuel tank is already full."]];
false
};
if (isNil QGVAR(SEconomyStore)) exitWith {
["ERROR", "Service economy store unavailable for garage refueling charge.", nil, nil] call EFUNC(common,log);
[CRPC(notifications,recieveNotification), ["danger", "Refueling", "Organization billing is unavailable. Refueling was not completed."], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Refueling", "Organization billing is unavailable. Refueling was not completed."]];
false
};
@ -79,7 +103,7 @@ GVAR(FEconomyStore) = createHashMapObject [[
private _totalCost = _totalLiters * GVAR(FuelCost);
private _chargeResult = GVAR(SEconomyStore) call ["chargeOrg", [_unit, _totalCost, "Refueling"]];
if !(_chargeResult getOrDefault ["success", false]) exitWith {
[CRPC(notifications,recieveNotification), ["danger", "Refueling", _chargeResult getOrDefault ["message", "Organization funds cannot cover this refuel. Refueling was not completed."]], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Refueling", _chargeResult getOrDefault ["message", "Organization funds cannot cover this refuel. Refueling was not completed."]]];
false
};
@ -88,7 +112,7 @@ GVAR(FEconomyStore) = createHashMapObject [[
private _formattedTotalCost = [_totalCost] call EFUNC(common,formatNumber);
private _formattedTotalLiters = _totalLiters toFixed 2;
[CRPC(notifications,recieveNotification), ["info", "Refueling", format ["Refueling complete: %1L<br />Organization charged $%2.", _formattedTotalLiters, _formattedTotalCost]], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "info", "Refueling", format ["Refueling complete: %1L<br />Organization charged $%2.", _formattedTotalLiters, _formattedTotalCost]]];
true
}],
["stop", {
@ -117,25 +141,25 @@ GVAR(FEconomyStore) = createHashMapObject [[
};
if (_totalCost <= 0) exitWith {
[CRPC(notifications,recieveNotification), ["info", "Refueling", format ["Refueling complete: %1L", _formattedTotalLiters]], _player] call CFUNC(targetEvent);
_self call ["notify", [_player, "info", "Refueling", format ["Refueling complete: %1L", _formattedTotalLiters]]];
_fuelRegistry deleteAt _index;
};
if (isNil QGVAR(SEconomyStore)) exitWith {
["ERROR", "Service economy store unavailable for refueling charge.", nil, nil] call EFUNC(common,log);
[CRPC(notifications,recieveNotification), ["danger", "Refueling", "Organization billing is unavailable. Refueling was not completed."], _player] call CFUNC(targetEvent);
_self call ["notify", [_player, "danger", "Refueling", "Organization billing is unavailable. Refueling was not completed."]];
_self call ["rollbackFuel", [_target, _initialFuel]];
_fuelRegistry deleteAt _index;
};
private _chargeResult = GVAR(SEconomyStore) call ["chargeOrg", [_player, _totalCost, "Refueling"]];
if !(_chargeResult getOrDefault ["success", false]) exitWith {
[CRPC(notifications,recieveNotification), ["danger", "Refueling", _chargeResult getOrDefault ["message", "Organization funds cannot cover this refuel. Refueling was not completed."]], _player] call CFUNC(targetEvent);
_self call ["notify", [_player, "danger", "Refueling", _chargeResult getOrDefault ["message", "Organization funds cannot cover this refuel. Refueling was not completed."]]];
_self call ["rollbackFuel", [_target, _initialFuel]];
_fuelRegistry deleteAt _index;
};
[CRPC(notifications,recieveNotification), ["info", "Refueling", format ["Refueling complete: %1L<br />Organization charged $%2.", _formattedTotalLiters, _formattedTotalCost]], _player] call CFUNC(targetEvent);
_self call ["notify", [_player, "info", "Refueling", format ["Refueling complete: %1L<br />Organization charged $%2.", _formattedTotalLiters, _formattedTotalCost]]];
_fuelRegistry deleteAt _index;
}]
]];

View File

@ -4,7 +4,7 @@
* File: fnc_initMEconomyStore.sqf
* Author: IDSolutions
* Date: 2025-12-20
* Last Update: 2026-04-18
* Last Update: 2026-05-15
* Public: No
*
* Description:
@ -66,6 +66,30 @@ GVAR(MEconomyStore) = createHashMapObject [[
} forEach _mSpawns;
};
}],
["notify", {
params [["_unit", objNull, [objNull]], ["_type", "info", [""]], ["_title", "Medical Billing", [""]], ["_message", "", [""]]];
if (isNull _unit || { _message isEqualTo "" }) exitWith { false };
private _uid = getPlayerUID _unit;
if (_uid isEqualTo "") exitWith { false };
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(notifications,recieveNotification), [_type, _title, _message], _unit] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_uid]],
["notificationType", _type],
["title", _title],
["message", _message]
],
createHashMapFromArray [["source", "economy"]]
]];
};
true
}],
["chargePlayer", {
params [["_uid", "", [""]], ["_amount", 0, [0]]];
@ -118,7 +142,18 @@ GVAR(MEconomyStore) = createHashMapObject [[
private _patch = _charge getOrDefault ["patch", createHashMap];
if (_patch isNotEqualTo createHashMap && { !(isNil QEGVAR(bank,BankMessenger)) }) then {
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_uid, _patch]];
if (isNil QEGVAR(common,EventBus)) then {
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_uid, _patch]];
} else {
EGVAR(common,EventBus) call ["emit", [
"bank.account.sync.requested",
createHashMapFromArray [
["uid", _uid],
["account", +_patch]
],
createHashMapFromArray [["source", "economy"]]
]];
};
};
private _savedAccount = EGVAR(bank,BankStore) call ["save", [_uid]];
@ -144,27 +179,27 @@ GVAR(MEconomyStore) = createHashMapObject [[
private _personalCharge = _self call ["chargePlayer", [_uid, _healCost]];
if (_personalCharge getOrDefault ["success", false]) exitWith {
private _sourceLabel = ["cash", "bank"] select ((_personalCharge getOrDefault ["source", "bank"]) isEqualTo "bank");
[CRPC(notifications,recieveNotification), ["info", "Medical Billing", format ["Medical service charged $%1 from your %2.", [_healCost] call EFUNC(common,formatNumber), _sourceLabel]], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "info", "Medical Billing", format ["Medical service charged $%1 from your %2.", [_healCost] call EFUNC(common,formatNumber), _sourceLabel]]];
[CRPC(actor,onActorHealed), [], _unit] call CFUNC(targetEvent);
};
if !(_personalCharge getOrDefault ["fallbackEligible", false]) exitWith {
private _message = _personalCharge getOrDefault ["message", "Personal funds could not be charged for medical service."];
[CRPC(notifications,recieveNotification), ["danger", "Medical Billing", _message], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Medical Billing", _message]];
};
if (isNil QGVAR(SEconomyStore)) exitWith {
["ERROR", "Service economy store unavailable for medical organization fallback charge.", nil, nil] call EFUNC(common,log);
[CRPC(notifications,recieveNotification), ["danger", "Medical Billing", "Organization billing is unavailable. Medical service cannot complete."], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Medical Billing", "Organization billing is unavailable. Medical service cannot complete."]];
};
private _chargeResult = GVAR(SEconomyStore) call ["chargeOrg", [_unit, _healCost, "Medical", true]];
if !(_chargeResult getOrDefault ["success", false]) exitWith {
private _message = _chargeResult getOrDefault ["message", "Organization funds cannot cover this medical service."];
[CRPC(notifications,recieveNotification), ["danger", "Medical Billing", _message], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Medical Billing", _message]];
};
[CRPC(notifications,recieveNotification), ["info", "Medical Billing", format ["Personal funds could not cover medical service. Organization charged $%1; repay it through your organization credit line.", [_healCost] call EFUNC(common,formatNumber)]], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "info", "Medical Billing", format ["Personal funds could not cover medical service. Organization charged $%1; repay it through your organization credit line.", [_healCost] call EFUNC(common,formatNumber)]]];
[CRPC(actor,onActorHealed), [], _unit] call CFUNC(targetEvent);
}],
["onRespawn", {

View File

@ -4,7 +4,7 @@
* File: fnc_initSEconomyStore.sqf
* Author: IDSolutions
* Date: 2025-12-20
* Last Update: 2026-04-18
* Last Update: 2026-05-15
* Public: No
*
* Description:
@ -34,7 +34,22 @@ GVAR(SEconomyStore) = createHashMapObject [[
if (isNull _unit || { _message isEqualTo "" }) exitWith { false };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _unit] call CFUNC(targetEvent);
private _uid = getPlayerUID _unit;
if (_uid isEqualTo "") exitWith { false };
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(notifications,recieveNotification), [_type, _title, _message], _unit] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_uid]],
["notificationType", _type],
["title", _title],
["message", _message]
],
createHashMapFromArray [["source", "economy"]]
]];
};
true
}],
["syncOrgPatch", {
@ -43,12 +58,24 @@ GVAR(SEconomyStore) = createHashMapObject [[
private _patch = _result getOrDefault ["patch", createHashMap];
if ((keys _patch) isEqualTo []) exitWith { false };
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_patch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["memberUids", []]);
private _memberUids = +(_result getOrDefault ["memberUids", []]);
if (isNil QEGVAR(common,EventBus)) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_patch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _memberUids;
} else {
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["memberUids", _memberUids],
["patch", +_patch]
],
createHashMapFromArray [["source", "economy"]]
]];
};
true
}],

View File

@ -1,3 +1,24 @@
#include "script_component.hpp"
call FUNC(initGarage);
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
if (isNil QGVAR(SyncEventTokens)) then {
private _sendVGarageSync = {
params ["_event"];
private _uid = _event getOrDefault ["uid", ""];
private _patch = _event getOrDefault ["patch", createHashMap];
if (_uid isEqualTo "" || { _patch isEqualTo createHashMap }) exitWith {};
private _player = [_uid] call EFUNC(common,getPlayer);
if (isNull _player) exitWith {};
[CRPC(garage,responseSyncVG), [_patch], _player] call CFUNC(targetEvent);
};
GVAR(SyncEventTokens) = [
EGVAR(common,EventBus) call ["on", ["garage.vgarage.sync.requested", _sendVGarageSync, "garage.vgarage.sync"]]
];
};

View File

@ -1,3 +1,39 @@
#include "script_component.hpp"
call FUNC(initLocker);
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
if (isNil QGVAR(SyncEventTokens)) then {
private _sendLockerSync = {
params ["_event"];
private _uid = _event getOrDefault ["uid", ""];
private _patch = _event getOrDefault ["patch", createHashMap];
if (_uid isEqualTo "" || { _patch isEqualTo createHashMap }) exitWith {};
private _player = [_uid] call EFUNC(common,getPlayer);
if (isNull _player) exitWith {};
[CRPC(locker,responseSyncLocker), [_patch], _player] call CFUNC(targetEvent);
};
private _sendVASync = {
params ["_event"];
private _uid = _event getOrDefault ["uid", ""];
private _patch = _event getOrDefault ["patch", createHashMap];
if (_uid isEqualTo "" || { _patch isEqualTo createHashMap }) exitWith {};
private _player = [_uid] call EFUNC(common,getPlayer);
if (isNull _player) exitWith {};
[CRPC(locker,responseSyncVA), [_patch], _player] call CFUNC(targetEvent);
};
GVAR(SyncEventTokens) = [
EGVAR(common,EventBus) call ["on", ["locker.sync.requested", _sendLockerSync, "locker.sync"]],
EGVAR(common,EventBus) call ["on", ["locker.va.sync.requested", _sendVASync, "locker.va.sync"]]
];
};

View File

@ -6,6 +6,67 @@ PREP_RECOMPILE_END;
// private _category = [QUOTE(MOD_NAME), LLSTRING(displayName)];
GVAR(RequestOrgSync) = {
params [["_memberUids", [], [[]]], ["_patch", createHashMap, [createHashMap]]];
if (_memberUids isEqualTo []) exitWith {};
if (isNil QEGVAR(common,EventBus)) exitWith {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_patch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _memberUids;
};
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["memberUids", +_memberUids],
["patch", +_patch]
],
createHashMapFromArray [["source", "org"]]
]];
};
GVAR(RequestNotification) = {
params [
["_uids", [], [[]]],
["_type", "info", [""]],
["_title", "", [""]],
["_message", "", [""]],
["_duration", -1, [0]]
];
if (_uids isEqualTo [] || { _message isEqualTo "" }) exitWith {};
if (isNil QEGVAR(common,EventBus)) exitWith {
private _params = [_type, _title, _message];
if (_duration >= 0) then { _params pushBack _duration; };
{
private _player = [_x] call EFUNC(common,getPlayer);
if (_player isNotEqualTo objNull) then {
[CRPC(notifications,recieveNotification), _params, _player] call CFUNC(targetEvent);
};
} forEach _uids;
};
private _payload = createHashMapFromArray [
["uids", +_uids],
["notificationType", _type],
["title", _title],
["message", _message]
];
if (_duration >= 0) then { _payload set ["duration", _duration]; };
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
_payload,
createHashMapFromArray [["source", "org"]]
]];
};
[QGVAR(requestInitOrg), {
params [["_uid", "", [""]]];
@ -71,12 +132,9 @@ PREP_RECOMPILE_END;
if (_result getOrDefault ["success", false]) then {
private _patch = _result getOrDefault ["patch", createHashMap];
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull && { _patch isNotEqualTo createHashMap }) then {
[CRPC(org,responseSyncOrg), [_patch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["memberUids", []]);
if (_patch isNotEqualTo createHashMap) then {
[_result getOrDefault ["memberUids", []], _patch] call GVAR(RequestOrgSync);
};
};
[CRPC(org,responseCreditLine), [createHashMapFromArray [
@ -100,14 +158,9 @@ PREP_RECOMPILE_END;
private _result = GVAR(OrgStore) call ["runPayroll", [_uid, _amount]];
if (_result getOrDefault ["success", false]) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["memberUids", []]);
[CRPC(org,responseSyncOrg), [createHashMap], _requester] call CFUNC(targetEvent);
private _syncTargets = +(_result getOrDefault ["memberUids", []]);
_syncTargets pushBackUnique _uid;
[_syncTargets, createHashMap] call GVAR(RequestOrgSync);
};
[CRPC(org,responseTreasuryAction), [createHashMapFromArray [
@ -133,14 +186,9 @@ PREP_RECOMPILE_END;
private _result = GVAR(OrgStore) call ["transferFunds", [_uid, _memberUid, _memberName, _amount]];
if (_result getOrDefault ["success", false]) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["memberUids", []]);
[CRPC(org,responseSyncOrg), [createHashMap], _requester] call CFUNC(targetEvent);
private _syncTargets = +(_result getOrDefault ["memberUids", []]);
_syncTargets pushBackUnique _uid;
[_syncTargets, createHashMap] call GVAR(RequestOrgSync);
};
[CRPC(org,responseTreasuryAction), [createHashMapFromArray [
@ -161,22 +209,9 @@ PREP_RECOMPILE_END;
private _result = GVAR(OrgStore) call ["inviteMember", [_uid, _targetUid, _targetName]];
if (_result getOrDefault ["success", false]) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach [_uid, _result getOrDefault ["targetUid", _targetUid]];
private _targetPlayer = [_result getOrDefault ["targetUid", _targetUid]] call EFUNC(common,getPlayer);
if (_targetPlayer isNotEqualTo objNull) then {
[CRPC(notifications,recieveNotification), [
"info",
"Organization Invite",
"You received an organization invite. Open the organization portal to accept or decline it.",
7000
], _targetPlayer] call CFUNC(targetEvent);
};
private _resolvedTargetUid = _result getOrDefault ["targetUid", _targetUid];
[[_uid, _resolvedTargetUid], createHashMap] call GVAR(RequestOrgSync);
[[_resolvedTargetUid], "info", "Organization Invite", "You received an organization invite. Open the organization portal to accept or decline it.", 7000] call GVAR(RequestNotification);
};
[CRPC(org,responseInviteOrg), [createHashMapFromArray [
@ -215,12 +250,7 @@ PREP_RECOMPILE_END;
} forEach (_orgData getOrDefault ["members", createHashMap]);
} forEach (_result getOrDefault ["affectedOrgIds", []]);
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _syncTargets;
[_syncTargets, createHashMap] call GVAR(RequestOrgSync);
};
[CRPC(org,responseInviteDecision), [createHashMapFromArray [
@ -255,12 +285,7 @@ PREP_RECOMPILE_END;
} forEach (_orgData getOrDefault ["members", createHashMap]);
} forEach (_result getOrDefault ["affectedOrgIds", []]);
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _syncTargets;
[_syncTargets, createHashMap] call GVAR(RequestOrgSync);
};
[CRPC(org,responseInviteDecision), [createHashMapFromArray [
@ -291,7 +316,8 @@ PREP_RECOMPILE_END;
private _notificationParams = _result getOrDefault ["notification", []];
if (_notificationParams isEqualType [] && { count _notificationParams > 0 }) then {
[CRPC(notifications,recieveNotification), _notificationParams, _player] call CFUNC(targetEvent);
private _duration = if ((count _notificationParams) > 3) then { _notificationParams # 3 } else { -1 };
[[_uid], _notificationParams # 0, _notificationParams # 1, _notificationParams # 2, _duration] call GVAR(RequestNotification);
};
};
@ -344,7 +370,8 @@ PREP_RECOMPILE_END;
private _notificationParams = _member getOrDefault ["notification", []];
if (_notificationParams isEqualType [] && { count _notificationParams > 0 }) then {
[CRPC(notifications,recieveNotification), _notificationParams, _memberPlayer] call CFUNC(targetEvent);
private _duration = if ((count _notificationParams) > 3) then { _notificationParams # 3 } else { -1 };
[[_memberUid], _notificationParams # 0, _notificationParams # 1, _notificationParams # 2, _duration] call GVAR(RequestNotification);
};
};
} forEach (_result getOrDefault ["members", []]);

View File

@ -4,7 +4,7 @@
* File: fnc_initOrgStore.sqf
* Author: IDSolutions
* Date: 2026-02-13
* Last Update: 2026-04-18
* Last Update: 2026-05-15
* Public: Yes
*
* Description:
@ -748,10 +748,34 @@ GVAR(OrgBaseStore) = compileFinal createHashMapFromArray [
private _currentBank = _account getOrDefault ["bank", 0];
private _patch = EGVAR(bank,BankStore) call ["mset", [_memberUid, createHashMapFromArray [["bank", _currentBank + _amount]], true]];
if (_patch isEqualTo createHashMap) exitWith { false };
if (isNil QEGVAR(common,EventBus)) then {
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_memberUid, _patch]];
} else {
EGVAR(common,EventBus) call ["emit", [
"bank.account.sync.requested",
createHashMapFromArray [
["uid", _memberUid],
["account", +_patch]
],
createHashMapFromArray [["source", "org"]]
]];
};
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_memberUid, _patch]];
if (_message isNotEqualTo "") then {
EGVAR(bank,BankMessenger) call ["sendNotification", [_memberUid, "info", "Treasury", _message]];
if (isNil QEGVAR(common,EventBus)) then {
EGVAR(bank,BankMessenger) call ["sendNotification", [_memberUid, "info", "Treasury", _message]];
} else {
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_memberUid]],
["notificationType", "info"],
["title", "Treasury"],
["message", _message]
],
createHashMapFromArray [["source", "org"]]
]];
};
};
true

View File

@ -238,19 +238,86 @@ GVAR(StorefrontBaseStore) = compileFinal createHashMapFromArray [
private _vgPatch = _result getOrDefault ["vgaragePatch", createHashMap];
private _bankPatch = _result getOrDefault ["bankPatch", createHashMap];
private _orgPatch = _result getOrDefault ["orgPatch", createHashMap];
private _uid = getPlayerUID _player;
if (keys _lockerPatch isNotEqualTo []) then { [CRPC(locker,responseSyncLocker), [_lockerPatch], _player] call CFUNC(targetEvent); };
if (keys _vaPatch isNotEqualTo []) then { [CRPC(locker,responseSyncVA), [_vaPatch], _player] call CFUNC(targetEvent); };
if (keys _vgPatch isNotEqualTo []) then { [CRPC(garage,responseSyncVG), [_vgPatch], _player] call CFUNC(targetEvent); };
if (keys _bankPatch isNotEqualTo []) then { [CRPC(bank,responseSyncBank), [_bankPatch], _player] call CFUNC(targetEvent); };
if (keys _lockerPatch isNotEqualTo []) then {
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(locker,responseSyncLocker), [_lockerPatch], _player] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"locker.sync.requested",
createHashMapFromArray [
["uid", _uid],
["patch", +_lockerPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
if (keys _vaPatch isNotEqualTo []) then {
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(locker,responseSyncVA), [_vaPatch], _player] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"locker.va.sync.requested",
createHashMapFromArray [
["uid", _uid],
["patch", +_vaPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
if (keys _vgPatch isNotEqualTo []) then {
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(garage,responseSyncVG), [_vgPatch], _player] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"garage.vgarage.sync.requested",
createHashMapFromArray [
["uid", _uid],
["patch", +_vgPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
if (keys _bankPatch isNotEqualTo []) then {
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(bank,responseSyncBank), [_bankPatch], _player] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"bank.account.sync.requested",
createHashMapFromArray [
["uid", _uid],
["account", +_bankPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
if (keys _orgPatch isNotEqualTo []) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_orgPatch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["orgTargetUids", []]);
private _orgTargetUids = +(_result getOrDefault ["orgTargetUids", []]);
if (isNil QEGVAR(common,EventBus)) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_orgPatch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _orgTargetUids;
} else {
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["memberUids", _orgTargetUids],
["patch", +_orgPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
true