#include "..\script_component.hpp" /* * Function: forge_server_admin_fnc_initAdminStore * Author: IDSolutions * * Description: * Initializes a server-side admin store interface for managing admin operations * Provides CRUD operations for admin data, including database persistence through ArmaDragonflyClient * * Creates a hashMap object with methods for: * - Sending messages to players * - Managing player data * - Performing administrative tasks * * Returns: * * Example: * private _adminStore = call forge_server_admin_fnc_initAdminStore; * _adminStore call ["sendMessage", [getPlayerUID player, "Hello, this is a test message"]]; */ private _adminStore = createHashMapObject [[ ["#type", "IAdminStore"], ["broadcastMessage", { params ["_message"]; [format ["Incoming Message from Field Commander:
%1", _message], "warning", 5] remoteExec ["forge_client_misc_fnc_notify", 0]; }], ["sendMessage", { params ["_uid", "_message"]; private _target = objNull; { if (getPlayerUID _x == _uid) exitWith { _target = _x; }; } forEach allPlayers; if (!isNull _target) then { [format ["Incoming Message from Field Commander:
%1", _message], "warning", 5] remoteExec ["forge_client_misc_fnc_notify", _target]; }; }], ["updatePaygrade", { params ["_uid", "_paygrade"]; private _target = objNull; { if (getPlayerUID _x == _uid) exitWith { _target = _x; }; } forEach allPlayers; if (!isNull _target) then { SETPVAR(_target,FORGE_PayGrade,_paygrade); }; }], ["handleTransfer", { params ["_condition", "_amount", "_uid"]; switch (_condition) do { case ("advance"): { private _target = objNull; { if (getPlayerUID _x == _uid) exitWith { _target = _x; }; } forEach allPlayers; if (isNull _target) exitWith {}; private _bank = GETVAR(_target,FORGE_Bank,0); private _newBalance = _bank + _amount; SETPVAR(_target,FORGE_Bank,_newBalance); }; case ("advanceAll"): { { private _player = _x; private _bank = GETVAR(_player,FORGE_Bank,0); private _newBalance = _bank + _amount; SETPVAR(_player,FORGE_Bank,_newBalance); } forEach allPlayers; }; case ("deduct"): { private _target = objNull; { if (getPlayerUID _x == _uid) exitWith { _target = _x; }; } forEach allPlayers; if (isNull _target) exitWith {}; private _bank = GETVAR(_target,FORGE_Bank,0); private _newBalance = _bank - _amount; if (_newBalance < 0) then { _newBalance = 0; }; SETPVAR(_target,FORGE_Bank,_newBalance); }; case ("payday"): { private _payGrades = (missionConfigFile >> "CfgPaygrades" >> "payGrades") call BIS_fnc_getCfgData; { private _player = _x; private _payGrade = GETVAR(_player,FORGE_PayGrade,nil); { _x params ["_payGradeIndex", "_payGradeBonus"]; if (_payGradeIndex == _payGrade) then { private _bank = GETVAR(_player,FORGE_Bank,0); private _newBalance = _bank + _payGradeBonus; SETPVAR(_player,FORGE_Bank,_newBalance); }; } forEach _payGrades; } forEach allPlayers; }; }; }] ]]; SETMVAR(FORGE_ADMIN_STORE_REG,_adminStore); GETMVAR(FORGE_ADMIN_STORE_REG,_adminStore);