#include "..\script_component.hpp"

params ["_unit", "_totalCost"];

private _preferredAccount = GETVAR(_unit,FORGE_Bank,0);
private _selectedAccount = ["FORGE_Cash", "FORGE_Bank"] select (_preferredAccount >= _totalCost);
private _accountBalance = _unit getVariable _selectedAccount;
private _newBalance = _accountBalance - _totalCost;

_unit setVariable [_selectedAccount, _newBalance, true];

[format ["Medical Services: %1 credited for treatment and recovery.", _totalCost], "blue-grey", 5] call EFUNC(misc,notify);