server/addons/admin/XEH_preInit_server.sqf
Jacob Schmidt 991ee5019a feat: Enhance admin and bank event handling with improved logging
This commit refines the event handling for both admin and bank functionalities, ensuring better clarity and consistency in logging.

Key changes include:

- Updated event names in admin handling to follow a consistent naming convention.
- Improved parameter handling in admin event functions, ensuring validation checks are in place.
- Enhanced logging messages to provide clearer context regarding the source of events and actions taken.
- Introduced bank event handling for deposit, transfer, withdrawal, and balance inquiries, with appropriate validation and logging.

These changes aim to improve the maintainability and readability of the codebase while ensuring robust event management.
2025-05-10 17:50:21 -05:00

56 lines
2.4 KiB
Plaintext

#include "script_component.hpp"
call FUNC(initAdmin);
call FUNC(initAdminStore);
[QGVAR(handleEvents), {
params ["_event", "_data"];
diag_log format ["[FORGE::Server::Admin::XEH_preInit] Received event: %1 with data: %2", _event, _data];
switch (_event) do {
case "ADMIN::ADVANCE::ALL": {
private _adminStore = call FUNC(verifyAdminStore);
_data params [["_amount", 0, [0]]];
if (_amount isEqualTo 0) exitWith { diag_log "[FORGE::Server::Admin::XEH_preInit::advanceAll] Invalid amount!"; };
_adminStore call ["handleTransfer", ["advanceAll", _amount]];
};
case "ADMIN::PAYDAY": {
private _adminStore = call FUNC(verifyAdminStore);
_adminStore call ["handleTransfer", ["payday"]];
};
case "ADMIN::TRANSFER": {
private _adminStore = call FUNC(verifyAdminStore);
_data params [["_condition", "", [""]], ["_amount", 0, [0]], ["_uid", "", [""]]];
if (_condition isEqualTo "" || _amount isEqualTo 0 || _uid isEqualTo "") exitWith { diag_log "[FORGE::Server::Admin::XEH_preInit::handleTransfer] Invalid condition, amount, or UID!"; };
_adminStore call ["handleTransfer", [_condition, _amount, _uid]];
};
case "ADMIN::SEND::MESSAGE": {
private _adminStore = call FUNC(verifyAdminStore);
_data params [["_uid", "", [""]], ["_message", "", [""]]];
if (_message isEqualTo "") exitWith { diag_log "[FORGE::Server::Admin::XEH_preInit::sendMessage] Invalid message!"; };
if (_uid isEqualTo "") then {
_adminStore call ["broadcastMessage", [_message]];
} else {
_adminStore call ["sendMessage", [_uid, _message]];
};
};
case "ADMIN::UPDATE::PAYGRADE": {
private _adminStore = call FUNC(verifyAdminStore);
_data params [["_uid", "", [""]], ["_paygrade", "", [""]]];
if (_uid isEqualTo "" || _paygrade isEqualTo "") exitWith { diag_log "[FORGE::Server::Admin::XEH_preInit::updatePaygrade] Invalid UID or paygrade!"; };
_adminStore call ["updatePaygrade", [_uid, _paygrade]];
};
default {
diag_log format ["[FORGE::Server::Admin::XEH_preInit] Unknown event: %1 with data: %2", _event, _data];
};
};
}] call CFUNC(addEventHandler);