#include "..\script_component.hpp" /* * Function: forge_client_admin_fnc_adminTransfer * Author: IDSolutions * * [Description] * Admin Transfer Menu * * Arguments: * None * * Return Value: * None * * Examples: * None * * Public: Yes */ params [["_condition", "", [""]]]; private _store = missionNamespace getVariable ["FORGE_ORG_STORE_REG", createHashMap]; private _org = _store call ["getOrg", []]; if (isNil "_org") exitWith { ["You are not in an organization!", "warning", 3] call EFUNC(misc,notify) }; private _orgFunds = _org get "funds"; private _dialog = findDisplay 202303; private _list = _dialog displayCtrl 2023001; private _targetValue = lbCurSel _list; private _data = _list lbData _targetValue; private _amount = round (parseNumber (ctrlText 2023005)); if ((isNil {_data})) exitWith { hint "You did not select a player!" }; { if (str (name (_x)) == str _data) then { private _target = _x; }; } count playableUnits; switch (_condition) do { case ("advance"): { private _bank = GETVAR(_target,FORGE_Bank,0); private _newBalance = _bank + _amount; if (_amount > _orgFunds) exitWith { ["Not enough money in the organization's account!", "warning", 3] call EFUNC(misc,notify) }; SETPVAR(_target,FORGE_Bank,_newBalance); ["deduct", _amount] call FUNC(adminRefresh); _store call ["updateFunds", -_amount]; }; case ("advanceAll"): { private _count = count playableUnits; if ((10000 * _count) > _orgFunds) exitWith { ["Not enough money in the organization's account!", "warning", 3] call EFUNC(misc,notify) }; { private _bank = GETVAR(_x,FORGE_Bank,0); private _newBalance = _bank + 10000; SETPVAR(_x,FORGE_Bank,_newBalance); } count playableUnits; ["deduct", (10000 * _count)] call FUNC(adminRefresh); _store call ["updateFunds", -(10000 * _count)]; }; case ("deduct"): { private _bank = GETVAR(_target,FORGE_Bank,0); private _newBalance = _bank - _amount; if (_amount > _bank) exitWith { ["Not enough money in the player's account!", "warning", 3] call EFUNC(misc,notify) }; SETPVAR(_target,FORGE_Bank,_newBalance); ["advance", _amount] call FUNC(adminRefresh); _store call ["updateFunds", _amount]; }; case ("payday"): { private _totalPayment = 0; private _paymentToDo = []; private _payGrades = (missionConfigFile >> "CfgPaygrades" >> "payGrades") call BIS_fnc_getCfgData; { private _player = _x; private _payGrade = GETVAR(_player,FORGE_PayGrade,nil); { _x params ["_payGradeIndex", "_payGradeBonus"]; if ((_x select 0) == _payGrade) then { _paymentToDo pushBack [_player, _payGradeBonus]; _totalPayment = _totalPayment + _payGradeBonus; }; } forEach _payGrades; } count playableUnits; if (_totalPayment > _orgFunds) exitWith { ["Not enough money in the organization's account!", "warning", 3] call EFUNC(misc,notify) }; { _x params ["_player", "_bonus"]; private _bank = GETVAR(_player,FORGE_Bank,0); private _newBalance = _bank + _bonus; SETPVAR(_player,FORGE_Bank,_newBalance); } count _paymentToDo; ["deduct", _totalPayment] call FUNC(adminRefresh); _store call ["updateFunds", -_totalPayment]; }; }; ctrlSetText [2023005, ""];