
This commit introduces significant changes to the admin panel, store, and arsenal systems, focusing on improved functionality, UI enhancements, and code optimization. **Admin Panel:** - Migrated to a web-based UI for improved user experience and maintainability. - Implemented dynamic player listing with filtering and search capabilities. - Added functionality for managing player paygrades, sending messages, and transferring funds. - Integrated server-side events for handling admin actions. **Store:** - Added `handleDelivery` event handler. - Streamlined product selection and purchase processes. - Improved handling of organization funds and player balances. - Refactored code for better readability and maintainability. **Arsenal:** - Enhanced initialization process with improved data validation. - Optimized item unlocking logic. These changes aim to provide a more robust, user-friendly, and efficient experience for both administrators and players.
96 lines
3.7 KiB
Plaintext
96 lines
3.7 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
[QGVAR(handleEvents), {
|
|
params ["_control", "_isConfirmDialog", "_message"];
|
|
|
|
diag_log format ["[FORGE: Admin] 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 _paygrade = GETVAR(_player,FORGE_PayGrade,QUOTE(E1));
|
|
private _funds = GETVAR(_player,FORGE_Bank,0);
|
|
|
|
private _playerInfo = createHashMapFromArray [
|
|
["uid", _uid],
|
|
["name", _name],
|
|
["paygrade", _paygrade],
|
|
["funds", _funds],
|
|
["side", str (side _player)]
|
|
];
|
|
|
|
_playerList pushBack _playerInfo;
|
|
} forEach allPlayers;
|
|
|
|
_playerData set ["players", _playerList];
|
|
_control ctrlWebBrowserAction ["ExecJS", format ["handlePlayerDataRequest(%1)", (toJSON _playerList)]];
|
|
};
|
|
case "REQUEST_PAYGRADE_DATA": {
|
|
private _payGrades = (missionConfigFile >> "CfgPaygrades" >> "payGrades") call BIS_fnc_getCfgData;
|
|
private _paygradeData = createHashMap;
|
|
private _paygradeList = [];
|
|
|
|
{
|
|
private _paygradeInfo = createHashMapFromArray [
|
|
["paygrade", _x select 0],
|
|
["bonus", _x select 1]
|
|
];
|
|
|
|
_paygradeList pushBack _paygradeInfo;
|
|
} forEach _payGrades;
|
|
|
|
_paygradeData set ["paygrades", _paygradeList];
|
|
_control ctrlWebBrowserAction ["ExecJS", format ["handlePaygradeDataRequest(%1)", (toJSON _paygradeList)]];
|
|
};
|
|
case "BROADCAST_MESSAGE": {
|
|
_data params ["_uid", "_message"];
|
|
|
|
if ((isNil "_message") || {_message isEqualTo ""}) exitWith { hintSilent "Message cannot be empty!"; };
|
|
|
|
["forge_server_admin_handleEvents", ["sendMessage", [_uid, _message]]] call CFUNC(serverEvent);
|
|
};
|
|
case "SEND_MESSAGE": {
|
|
_data params ["_uid", "_message"];
|
|
|
|
if ((isNil "_uid") || {_uid isEqualTo ""}) exitWith { hintSilent "You did not select a player!"; };
|
|
|
|
["forge_server_admin_handleEvents", ["sendMessage", [_uid, _message]]] call CFUNC(serverEvent);
|
|
};
|
|
case "UPDATE_PAYGRADE": {
|
|
private _uid = _data select 0;
|
|
private _paygrade = _data select 1;
|
|
|
|
if ((isNil "_uid") || {_uid isEqualTo ""}) exitWith { hintSilent "You did not select a player!"; };
|
|
|
|
["forge_server_admin_handleEvents", ["updatePaygrade", [_uid, _paygrade]]] call CFUNC(serverEvent);
|
|
};
|
|
case "HANDLE_TRANSFER": {
|
|
private _condition = _data select 0;
|
|
private _amount = _data select 1;
|
|
private _uid = _data select 2;
|
|
|
|
["forge_server_admin_handleEvents", ["handleTransfer", [_condition, _amount, _uid]]] call CFUNC(serverEvent);
|
|
};
|
|
case "ADVANCE_ALL": {
|
|
private _amount = _data select 0;
|
|
|
|
["forge_server_admin_handleEvents", ["advanceAll", [_amount]]] call CFUNC(serverEvent);
|
|
};
|
|
case "HANDLE_PAYDAY": {
|
|
["forge_server_admin_handleEvents", ["handlePayday"]] call CFUNC(serverEvent);
|
|
};
|
|
default {
|
|
diag_log format ["[FORGE: Admin] Unhandled event: %1", _event];
|
|
};
|
|
};
|
|
}] call CFUNC(addEventHandler); |