client/addons/bank/XEH_postInit_client.sqf
Jacob Schmidt 90476345db feat: Enhance admin and bank systems with event handling and UI improvements
This commit introduces significant updates to the admin and bank systems, focusing on improved event handling and user interface enhancements. Key changes include:

- Refactored event handling for player data requests, paygrade updates, and message broadcasting in the admin panel.
- Implemented new event types for handling player funds and transaction history in the bank system.
- Updated JavaScript functions for better interaction with the web-based UI, including dynamic data requests and improved user feedback.
- Removed deprecated functions and streamlined code for better maintainability.

These enhancements aim to provide a more efficient and user-friendly experience for administrators and players alike.
2025-05-10 17:50:11 -05:00

86 lines
3.5 KiB
Plaintext

#include "script_component.hpp"
[QGVAR(handleEvents), {
params ["_control", "_isConfirmDialog", "_message"];
diag_log text format ["[FORGE::Client::Bank::XEH_postInit] Received event: '%1'", _message];
_message = fromJSON _message;
private _event = _message get "event";
private _data = _message get "data";
switch (_event) do {
case "REQUEST::PLAYER::DATA": {
private _playerData = createHashMap;
private _playerList = [];
{
private _player = _x;
private _uid = getPlayerUID _player;
private _name = name _player;
private _funds = GETVAR(_player,FORGE_Bank,0); //TODO: Implement funds from server
private _cash = GETVAR(_player,FORGE_Cash,0); //TODO: Implement cash from server
private _playerInfo = createHashMapFromArray [
["uid", _uid],
["name", _name],
["funds", _funds],
["cash", _cash]
];
_playerList pushBack _playerInfo;
} forEach allPlayers;
_playerData set ["players", _playerList];
_control ctrlWebBrowserAction ["ExecJS", format ["handlePlayerDataRequest(%1)", (toJSON _playerList)]];
};
case "REQUEST::PLAYER::FUNDS": {
private _playerData = createHashMap;
private _uid = getPlayerUID player;
private _balance = GETVAR(_player,FORGE_Bank,0); //TODO: Implement balance from server
private _cash = GETVAR(_player,FORGE_Cash,0); //TODO: Implement cash from server
private _playerData = createHashMapFromArray [
["balance", _balance],
["cash", _cash]
];
_control ctrlWebBrowserAction ["ExecJS", format ["handlePlayerFundsRequest(%1)", (toJSON _playerData)]];
};
case "REQUEST::TRANSACTION::HISTORY": {
private _uid = getPlayerUID player;
private _history = []; //TODO: Implement history from server
private _historyData = createHashMapFromArray [["history", _history]];
_control ctrlWebBrowserAction ["ExecJS", format ["handleTransactionHistoryRequest(%1)", (toJSON _historyData)]];
};
case "DEPOSIT::FUNDS": {
_data params ["_amount"];
if (_amount <= 0) exitWith { systemChat "Invalid amount, must be greater than 0!"; false };
["forge_server_bank_handleEvents", ["BANK::DEPOSIT", [getPlayerUID player, _amount]]] call CFUNC(serverEvent);
true
};
case "WITHDRAW::FUNDS": {
_data params ["_amount"];
if (_amount <= 0) exitWith { systemChat "Invalid amount, must be greater than 0!"; false };
["forge_server_bank_handleEvents", ["BANK::WITHDRAW", [getPlayerUID player, _amount]]] call CFUNC(serverEvent);
true
};
case "TRANSFER::FUNDS": {
_data params ["_amount", "_toUid"];
if ((_amount <= 0) || {_toUid isEqualTo ""}) exitWith { systemChat "Invalid UID or amount, UID cannot be empty and amount must be greater than 0!"; false };
["forge_server_bank_handleEvents", ["BANK::TRANSFER", [getPlayerUID player, _toUid, _amount]]] call CFUNC(serverEvent);
true
};
default {
diag_log format ["[FORGE::Client::Bank::XEH_postInit] Unhandled event: %1", _event];
};
};
}] call CFUNC(addEventHandler);