server/addons/admin/XEH_preInit_server.sqf
Jacob Schmidt eec98d03eb
All checks were successful
Build / Build (push) Successful in 25s
feat: Implement admin event handling and improve player data saving
This commit introduces admin event handling to manage various administrative actions and enhances the player data saving process.

The following changes were made:

-   Implemented event handling for admin actions such as advancing funds, handling paydays, transferring funds, sending messages, and updating paygrades. These events are triggered via the `QGVAR(handleEvents)` event handler.
-   Added `initAdminStore` and `verifyAdminStore` functions to manage the admin store.
-   Refactored the `fnc_handleDisconnect.sqf` script to use the `GETVAR` macro for retrieving player data, ensuring consistency and readability.
-   Replaced hardcoded default values with `QUOTE()` wrapped values in `fnc_handleDisconnect.sqf` for better maintainability and configuration.
2025-05-03 19:33:45 -05:00

56 lines
2.0 KiB
Plaintext

#include "script_component.hpp"
call FUNC(initAdmin);
call FUNC(initAdminStore);
[QGVAR(handleEvents), {
params ["_event", "_params"];
diag_log format ["[FORGE: Admin] Received event: %1 with params: %2", _event, _params];
switch (_event) do {
case "advanceAll": {
private _adminStore = call FUNC(verifyAdminStore);
_params params ["_amount"];
if (isNil "_amount") exitWith { diag_log "Amount cannot be empty!"; };
_adminStore call ["handleTransfer", ["advanceAll", _amount]];
};
case "handlePayday": {
private _adminStore = call FUNC(verifyAdminStore);
_adminStore call ["handleTransfer", ["payday"]];
};
case "handleTransfer": {
private _adminStore = call FUNC(verifyAdminStore);
_params params ["_condition", "_amount", "_uid"];
if (isNil "_condition") exitWith { diag_log "Condition cannot be empty!"; };
_adminStore call ["handleTransfer", [_condition, _amount, _uid]];
};
case "sendMessage": {
private _adminStore = call FUNC(verifyAdminStore);
_params params ["_uid", "_message"];
if (isNil "_message") exitWith { diag_log "Message cannot be empty!"; };
if (_uid isEqualTo "") then {
_adminStore call ["broadcastMessage", [_message]];
} else {
_adminStore call ["sendMessage", [_uid, _message]];
};
};
case "updatePaygrade": {
private _adminStore = call FUNC(verifyAdminStore);
_params params ["_uid", "_paygrade"];
if (_uid isEqualTo "" && _paygrade isEqualTo "") exitWith { diag_log "UID or Paygrade cannot be empty!"; };
_adminStore call ["updatePaygrade", [_uid, _paygrade]];
};
default {
diag_log format ["Unknown event: %1 with params: %2", _event, _params];
};
};
}] call CFUNC(addEventHandler);