Implemented features: - High-performance Rust extension with Redis persistence - Actor/player management with loadout, position, and state tracking - Banking system with deposit, withdraw, and transfer operations - Physical and virtual garage/locker systems for vehicle and equipment storage - Organization management with member tracking and permissions - Client-side UI with React-like state management - Server-side event-driven architecture with CBA Events - Security: Self-transfer prevention at multiple layers - Logging system with per-module log files - ICOM module for inter-server communication Co-Authored-By: Warp <agent@warp.dev>
112 lines
4.7 KiB
Plaintext
112 lines
4.7 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
PREP_RECOMPILE_START;
|
|
#include "XEH_PREP.hpp"
|
|
PREP_RECOMPILE_END;
|
|
|
|
// private _category = [QUOTE(MOD_NAME), LLSTRING(displayName)];
|
|
|
|
[QGVAR(requestInitBank), {
|
|
params [["_uid", "", [""]], ["_bank", createHashMap, [createHashMap]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID!" };
|
|
if (_bank isEqualTo createHashMap) exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid Bank data!" };
|
|
|
|
GVAR(BankStore) call ["init", [_uid, _bank]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestGetBank), {
|
|
params [["_uid", "", [""]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID!" };
|
|
|
|
private _session = EGVAR(actor,PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid Session!" };
|
|
|
|
GVAR(BankStore) call ["get", [_uid, _sync]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestSetBank), {
|
|
params [["_uid", "", [""]], ["_key", "", [""]], ["_value", nil, [[], "", 0, false, createHashMap]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "" || _key isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID or Key!" };
|
|
|
|
private _session = EGVAR(actor,PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid Session!" };
|
|
|
|
GVAR(BankStore) call ["set", [_uid, _key, _value, _sync]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestMSetBank), {
|
|
params [["_uid", "", [""]], ["_fieldValuePairs", createHashMap, [createHashMap]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID!" };
|
|
if ((_fieldValuePairs isEqualTo createHashMap) || !(_fieldValuePairs isEqualType createHashMap)) exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid field pairs!" };
|
|
|
|
private _session = EGVAR(actor,PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid Session!" };
|
|
|
|
GVAR(BankStore) call ["mset", [_uid, _fieldValuePairs, _sync]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestSaveBank), {
|
|
params [["_uid", "", [""]], ["_sync", false, [false]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID!" };
|
|
|
|
private _session = EGVAR(actor,PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid Session!" };
|
|
|
|
GVAR(BankStore) call ["save", [_uid, _sync]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestRemoveBank), {
|
|
params [["_uid", "", [""]]];
|
|
|
|
if (_uid isEqualTo "") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID!" };
|
|
|
|
GVAR(BankStore) call ["remove", [_uid]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestDeposit), {
|
|
params [["_uid", "", [""]], ["_amount", 0, [0]]];
|
|
|
|
if (_uid isEqualTo "" || _amount isEqualTo 0) exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID or Amount!" };
|
|
|
|
private _session = EGVAR(actor,PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid Session!" };
|
|
|
|
GVAR(BankStore) call ["deposit", [_uid, _amount]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestTransfer), {
|
|
params [["_uid", "", [""]], ["_target", "", [""]], ["_from", "", [""]], ["_amount", 0, [0]]];
|
|
|
|
if (_uid isEqualTo "" || _target isEqualTo "" || _from isEqualTo "" || _amount isEqualTo 0) exitWith {
|
|
diag_log "[FORGE:Server:Bank] Empty/Invalid UID, Target, From Account, or Amount!"
|
|
};
|
|
|
|
// Prevent self-transfers (security check)
|
|
if (_uid isEqualTo _target) exitWith {
|
|
diag_log format ["[FORGE:Server:Bank] SECURITY: Player %1 attempted self-transfer!", _uid];
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
[CRPC(notifications,recieveNotification), ["error", "Bank", "Cannot transfer to yourself!"], _player] call CFUNC(targetEvent);
|
|
};
|
|
|
|
private _session = EGVAR(actor,PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid Session!" };
|
|
|
|
GVAR(BankStore) call ["transfer", [_uid, _target, _from, _amount]];
|
|
}] call CFUNC(addEventHandler);
|
|
|
|
[QGVAR(requestWithdraw), {
|
|
params [["_uid", "", [""]], ["_amount", 0, [0]]];
|
|
|
|
if (_uid isEqualTo "" || _amount isEqualTo 0) exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid UID or Amount!" };
|
|
|
|
private _session = EGVAR(actor,PlayerSessions) getOrDefault [_uid, nil];
|
|
if (isNil "_session") exitWith { diag_log "[FORGE:Server:Bank] Empty/Invalid Session!" };
|
|
|
|
GVAR(BankStore) call ["withdraw", [_uid, _amount]];
|
|
}] call CFUNC(addEventHandler);
|