#include "..\script_component.hpp"

private _display = findDisplay IDD_BANKDIALOG;
private _input = _display displayCtrl IDC_AMOUNTINPUT;
private _amount = parseNumber (ctrlText _input);

// private _bank = player getVariable ["FORGE_Bank", 0];
// private _cash = player getVariable ["FORGE_Cash", 0];
private _bank = GETVAR(player,FORGE_Bank,0);
private _cash = GETVAR(player,FORGE_Cash,0);

if (_amount > 0 && _amount <= _bank) then {
    _bank = _bank - _amount;
    _cash = _cash + _amount;

    // player setVariable ["FORGE_Bank", _bank, true];
    // player setVariable ["FORGE_Cash", _cash, true];
    SETPVAR(player,FORGE_Bank,_bank);
    SETPVAR(player,FORGE_Cash,_cash);

    // [] call forge_client_bank_fnc_refresh;
    [] call FUNC(refresh);
    // hint "Money withdrawn successfully";
    [format ["Money withdrawn successfully"], "info", 3, "right"] call EFUNC(misc,notify);
} else {
    // hint "Invalid amount";
    [format ["Invalid amount"], "warning", 3, "right"] call EFUNC(misc,notify);
};