How to add a button in atm ?
I copy and edit the file "deposit.sqf" and created the file "depositall.sqf", more not work
code:
#include "gui_defines.hpp"
#define ERR_NOT_ENOUGH_FUNDS "You don't have enough money."
#define ERR_MAX_BALANCE "Your account has reached the maximum balance."
disableSerialization;
private ["_dialog", "_input", "_amount", "_balance", "_maxBalance"];
_dialog = findDisplay AtmGUI_IDD;
if (isNull _dialog) exitWith {};
_input = _dialog displayCtrl AtmAmountInput_IDC;
_amount = player getVariable ["cmoney", 0];
if (_amount < 1) exitWith {};
if (player getVariable ["cmoney", 0] < _amount) exitWith
{
[ERR_NOT_ENOUGH_FUNDS, 5] call mf_notify_client;
playSound "FD_CP_Not_Clear_F";
};
_balance = player getVariable ["bmoney", 0];
_maxBalance = ["A3W_atmMaxBalance", 1000000] call getPublicVar;
if (_balance + _amount > _maxBalance) then
{
_amount = 0 max (_maxBalance - _balance);
};
if (_amount < 1) exitWith
{
[ERR_MAX_BALANCE, 5] call mf_notify_client;
playSound "FD_CP_Not_Clear_F";
};
_input ctrlSetText (_amount call fn_numToStr);
if (!isServer) then { player setVariable ["cmoney", (player getVariable ["cmoney", 0]) - _amount, false] }; // temp client-side update, do not set to true
// pvar_processTransaction = ["atm", player, _amount];
// publicVariableServer "pvar_processTransaction";
["atm", player, _amount] call A3W_fnc_processTransaction;
I edit more files, for the above file to work, this files are: "gui_defines.hpp", "atm_gui.hpp", "select_account.sqf" and "init.sqf"
codes:
gui_defines.hpp:
// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
// @file Name: gui_defines.hpp
// @file Author: AgentRev
#define AtmGUI_IDD 63211
#define AtmBalanceText_IDC 1010
#define AtmAmountInput_IDC 1020
#define AtmBountyCheckbox_IDC 1025
#define AtmBountyLabel_IDC 1026
#define AtmAccountDropdown_IDC 1030
#define AtmFeeLabel_IDC 1035
#define AtmFeeText_IDC 1040
#define AtmTotalLabel_IDC 1045
#define AtmTotalText_IDC 1050
#define AtmDepositButton_IDC 2010
#define AtmDepositAllButton_IDC 2040
#define AtmWithdrawButton_IDC 2020
#define AtmCancelButton_IDC 2030
atm_gui.hpp
// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
// @file Name: atm_gui.hpp
// @file Author: AgentRev
#include "gui_defines.hpp"
class AtmGUI
{
idd = AtmGUI_IDD;
movingEnable = true;
enableSimulation = true;
controls[] = {AtmBalanceHead, AtmBalanceText, AtmAmountLabel, AtmAmountInput, AtmBountyCheckbox, AtmBountyLabel, AtmAccountLabel, AtmAccountDropdown, AtmFeeLabel, AtmFeeText, AtmTotalLabel, AtmTotalText, AtmDepositButton, AtmWithdrawButton, AtmCancelButton};
controlsBackground[] = {AtmBG, AtmTopBG, AtmTopLogo, AtmBalanceBG};
#define Atm_TEXT_SIZE (0.04 * TEXT_SCALE)
class AtmLabelText : w_RscText {
sizeEx = Atm_TEXT_SIZE;
};
class AtmBG : IGUIBack
{
idc = -1;
colorBackground[] = {0, 0, 0, 0.6};
#define AtmBG_W (0.5 * X_SCALE)
#define AtmBG_H (0.4 * Y_SCALE)
#define AtmBG_X (0.5 - (AtmBG_W / 2)) // middle of screen
#define AtmBG_Y (0.5 - (AtmBG_H / 2)) // middle of screen
x = AtmBG_X;
y = AtmBG_Y;
w = AtmBG_W;
h = AtmBG_H;
};
class AtmTopBG : IGUIBack
{
idc = -1;
colorBackground[] = {A3W_UICOLOR_R, A3W_UICOLOR_G, A3W_UICOLOR_B, 0.8};
#define AtmTopBG_Y AtmBG_Y
#define AtmTopBG_H (0.08 * Y_SCALE)
x = AtmBG_X;
y = AtmTopBG_Y;
w = AtmBG_W;
h = AtmTopBG_H;
};
class AtmTopLogo : w_RscPicture
{
idc = -1;
text = "client\icons\suatmm_logo.paa";
#define AtmTopLogo_W (0.08 * X_SCALE)
#define AtmTopLogo_H (0.08 * Y_SCALE)
#define AtmTopLogo_X (AtmBG_X + CENTER(AtmBG_W, AtmTopLogo_W))
#define AtmTopLogo_Y (AtmTopBG_Y + CENTER(AtmTopBG_H, AtmTopLogo_H))
x = AtmTopLogo_X;
y = AtmTopLogo_Y;
w = AtmTopLogo_W;
h = AtmTopLogo_H;
};
#define Atm_OUTER_MARGIN_X (0.02 * X_SCALE)
#define Atm_OUTER_MARGIN_Y (0.02 * Y_SCALE)
#define Atm_INNER_MARGIN_X (0.01 * X_SCALE)
#define Atm_INNER_MARGIN_Y (0.01 * Y_SCALE)
#define AtmBalanceBG_W (AtmBG_W - (Atm_OUTER_MARGIN_X * 2))
#define AtmBalanceBG_X (AtmBG_X + Atm_OUTER_MARGIN_X)
#define AtmBalanceBG_Y (AtmTopBG_Y + AtmTopBG_H + Atm_OUTER_MARGIN_Y)
class AtmBalanceHead : w_RscStructuredText
{
idc = -1;
text = "<t underline='true' shadow='0'>Balance</t>";
size = 0.035 * TEXT_SCALE;
#define AtmBalanceHead_W AtmBalanceBG_W
#define AtmBalanceHead_H (0.022 * Y_SCALE)
#define AtmBalanceHead_X AtmBalanceBG_X
#define AtmBalanceHead_Y (AtmBalanceBG_Y + (Atm_INNER_MARGIN_Y / 2))
x = AtmBalanceHead_X;
y = AtmBalanceHead_Y;
w = AtmBalanceHead_W;
h = AtmBalanceHead_H;
};
class AtmBalanceText : w_RscStructuredText
{
idc = AtmBalanceText_IDC;
text = "$0";
size = 0.06 * TEXT_SCALE;
class Attributes : Attributes {
color = "#80FF80";
align = "center";
};
#define AtmBalanceText_W AtmBalanceBG_W
#define AtmBalanceText_H (0.03 * Y_SCALE)
#define AtmBalanceText_X AtmBalanceBG_X
#define AtmBalanceText_Y (AtmBalanceHead_Y + AtmBalanceHead_H)
x = AtmBalanceText_X;
y = AtmBalanceText_Y;
w = AtmBalanceText_W;
h = AtmBalanceText_H;
};
class AtmBalanceBG : IGUIBack
{
idc = -1;
colorBackground[] = {0.15, 0.15, 0.15, 0.9};
#define AtmBalanceBG_H ((AtmBalanceText_Y - AtmBalanceBG_Y) + AtmBalanceText_H + Atm_INNER_MARGIN_Y)
x = AtmBalanceBG_X;
y = AtmBalanceBG_Y;
w = AtmBalanceBG_W;
h = AtmBalanceBG_H;
};
#define AtmLabel_W (0.08 * X_SCALE)
#define AtmLabel_H (0.02 * Y_SCALE)
#define AtmLabel_X (AtmBG_X + Atm_OUTER_MARGIN_X)
#define AtmBountyLabel_W (0.06 * X_SCALE)
#define AtmBountyLabel_X ((AtmBalanceBG_X + AtmBalanceBG_W) - AtmBountyLabel_W)
#define AtmBountyLabel_Y (AtmAmountInput_Y + (AtmLabel_Y_OFFSET/2))
#define AtmBountyCheckbox_W (0.028 * Y_SCALE)
#define AtmBountyCheckbox_H (0.028 * Y_SCALE)
#define AtmBountyCheckbox_X ((AtmBountyLabel_X - AtmBountyCheckbox_W) + (0.003 * X_SCALE))
#define AtmBountyCheckbox_Y (AtmAmountInput_Y)
#define AtmInput_X (AtmLabel_X + AtmLabel_W + Atm_INNER_MARGIN_X)
#define AtmAmountInput_W ((AtmBountyCheckbox_X - AtmInput_X) - Atm_INNER_MARGIN_X)
#define AtmInput_W (AtmBG_W - ((AtmInput_X - AtmLabel_X) + (Atm_OUTER_MARGIN_X * 2)))
#define AtmInput_H (0.028 * Y_SCALE)
#define AtmInput_Y_START (AtmBalanceBG_Y + AtmBalanceBG_H + Atm_OUTER_MARGIN_Y)
#define AtmInput_Y_MARGIN (AtmInput_H + Atm_INNER_MARGIN_Y)
#define AtmLabel_Y_OFFSET CENTER(AtmInput_H, AtmLabel_H)
#define AtmAmountInput_Y AtmInput_Y_START
class AtmAmountLabel : AtmLabelText
{
idc = -1;
text = "Amount:";
#define AtmAmountLabel_Y (AtmAmountInput_Y + AtmLabel_Y_OFFSET)
x = AtmLabel_X;
y = AtmAmountLabel_Y;
w = AtmLabel_W;
h = AtmLabel_H;
};
class AtmAmountInput : RscEdit
{
idc = AtmAmountInput_IDC;
text = "";
sizeEx = Atm_TEXT_SIZE;
x = AtmInput_X;
y = AtmAmountInput_Y;
w = AtmAmountInput_W;
h = AtmInput_H;
};
class AtmBountyCheckbox
{
idc = AtmBountyCheckbox_IDC;
type = 77;
style = 0;
checked = 0;
tooltip = "Place a Bounty on your enemies head.\nThe bounty will be rewarded to the killer of that target.\nThe bounty killer and target are NOT allowed\nto work together or join the same group.";
color[] = {1, 1, 1, 0.7};
colorFocused[] = {1, 1, 1, 1};
colorHover[] = {1, 1, 1, 1};
colorPressed[] = {1, 1, 1, 1};
colorDisabled[] = {1, 1, 1, 0.2};
colorBackground[] = {0, 0, 0, 0};
colorBackgroundFocused[] = {0, 0, 0, 0};
colorBackgroundHover[] = {0, 0, 0, 0};
colorBackgroundPressed[] = {0, 0, 0, 0};
colorBackgroundDisabled[] = {0, 0, 0, 0};
textureChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
textureUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";
textureFocusedChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
textureFocusedUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";
textureHoverChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
textureHoverUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";
texturePressedChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
texturePressedUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";
textureDisabledChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
textureDisabledUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";
soundEnter[] = {1, 1, 1, 1};
soundPush[] = {1, 1, 1, 1};
soundClick[] = {1, 1, 1, 1};
soundEscape[] = {1, 1, 1, 1};
x = AtmBountyCheckbox_X;
y = AtmBountyCheckbox_Y;
w = AtmBountyCheckbox_W;
h = AtmBountyCheckbox_H;
};
class AtmBountyLabel : AtmLabelText
{
idc = AtmBountyLabel_IDC;
text = "Bounty";
x = AtmBountyLabel_X;
y = AtmBountyLabel_Y;
w = AtmBountyLabel_W;
h = AtmLabel_H;
};
#define AtmAccountDropdown_Y (AtmAmountInput_Y + AtmInput_Y_MARGIN)
class AtmAccountLabel : AtmLabelText
{
idc = -1;
text = "Account:";
#define AtmAccountLabel_Y (AtmAccountDropdown_Y + AtmLabel_Y_OFFSET)
x = AtmLabel_X;
y = AtmAccountLabel_Y;
w = AtmLabel_W;
h = AtmLabel_H;
};
class AtmAccountDropdown : RscCombo
{
idc = AtmAccountDropdown_IDC;
sizeEx = Atm_TEXT_SIZE;
wholeHeight = 0.35 * Y_SCALE;
colorBackground[] = {0, 0, 0, 0.6};
x = AtmInput_X;
y = AtmAccountDropdown_Y;
w = AtmInput_W;
h = AtmInput_H;
};
#define AtmFeeText_Y (AtmAccountDropdown_Y + AtmInput_Y_MARGIN)
class AtmFeeLabel : AtmLabelText
{
idc = AtmFeeLabel_IDC;
text = "Fee:";
#define AtmFeeLabel_Y (AtmFeeText_Y + AtmLabel_Y_OFFSET)
x = AtmLabel_X;
y = AtmFeeLabel_Y;
w = AtmLabel_W;
h = AtmLabel_H;
};
class AtmFeeText : AtmLabelText
{
idc = AtmFeeText_IDC;
text = "$0";
colorBackground[] = {0, 0, 0, 0.4};
x = AtmInput_X;
y = AtmFeeText_Y;
w = AtmInput_W;
h = AtmInput_H;
};
#define AtmTotalText_Y (AtmFeeText_Y + AtmInput_Y_MARGIN)
class AtmTotalLabel : AtmLabelText
{
idc = AtmTotalLabel_IDC;
text = "Total:";
#define AtmTotalLabel_Y (AtmTotalText_Y + AtmLabel_Y_OFFSET)
x = AtmLabel_X;
y = AtmTotalLabel_Y;
w = AtmLabel_W;
h = AtmLabel_H;
};
class AtmTotalText : AtmLabelText
{
idc = AtmTotalText_IDC;
text = "$0";
colorBackground[] = {0, 0, 0, 0.4};
x = AtmInput_X;
y = AtmTotalText_Y;
w = AtmInput_W;
h = AtmInput_H;
};
#define AtmButton_W ((AtmBG_W - ((Atm_OUTER_MARGIN_X * 2) + (Atm_INNER_MARGIN_X * 2))) / 3)
#define AtmButton_H (0.033 * Y_SCALE)
#define AtmButton_Y ((AtmBG_Y + AtmBG_H) - (Atm_OUTER_MARGIN_Y + AtmButton_H))
class AtmButton : w_RscButton
{
sizeEx = Atm_TEXT_SIZE;
y = AtmButton_Y;
w = AtmButton_W;
h = AtmButton_H;
};
class AtmGreenButton : AtmButton
{
colorBackground[] = {0, 0.5, 0, 1}; // normal
colorFocused[] = {0, 0.3, 0, 1}; // pulse
colorBackgroundActive[] = {0, 0.6, 0, 1}; // hover
};
class AtmDepositButton : AtmGreenButton
{
idc = AtmDepositButton_IDC;
text = "Deposit";
// action is defined in client\items\atm\select_account.sqf
#define AtmDepositButton_X (AtmBG_X + Atm_OUTER_MARGIN_X)
x = AtmDepositButton_X;
};
class AtmDepositAllButton : AtmGreenButton
{
idc = AtmDepositAllButton_IDC;
text = "Deposit All";
// action is defined in client\items\atm\select_account.sqf
#define AtmDepositAllButton_X (AtmDepositButton_X + Atm_INNER_MARGIN_X)
x = AtmDepositAllButton_X;
};
class AtmWithdrawButton : AtmGreenButton
{
idc = AtmWithdrawButton_IDC;
text = "Withdraw";
action = "call mf_items_atm_withdraw";
#define AtmWithdrawButton_X (AtmDepositAllButton_X + AtmButton_W + Atm_INNER_MARGIN_X)
x = AtmWithdrawButton_X;
};
class AtmCancelButton : AtmButton
{
idc = AtmCancelButton_IDC;
text = "Cancel";
action = "closeDialog 0";
#define AtmCancelButton_X (AtmWithdrawButton_X + AtmButton_W + Atm_INNER_MARGIN_X)
x = AtmCancelButton_X;
};
};
select_account.sqf
private ["_accDropdown", "_curSel", "_dialog", "_deposit", "_depositall", "_withdraw", "_bountyCheckbox", "_bountyChecked", "_selAcc", "_accDropdown", "_feeText", "_totalText", "_players", "_oldPlayers", "_strPlayers", "_selData", "_selAcc", "_idx", "_data", "_selIdx", "_amount", "_fee", "_deposit", "_depositall", "_withdraw"];
_accDropdown = _this select 0;
_curSel = _this select 1;
_dialog = ctrlParent _accDropdown;
_deposit = _dialog displayCtrl AtmDepositButton_IDC;
_depositall = _dialog displayCtrl AtmDepositAllButton_IDC;
_withdraw = _dialog displayCtrl AtmWithdrawButton_IDC;
_bountyCheckbox = _dialog displayCtrl AtmBountyCheckbox_IDC;
_bountyChecked = cbChecked _bountyCheckbox;
_selAcc = call compile (_accDropdown lbData _curSel);
if(!_bountyChecked)then{
if (!isNil "_selAcc" && {_selAcc != player}) then
{
_deposit ctrlSetText "Transfer";
_deposit buttonSetAction "call mf_items_atm_transfer";
if (ctrlShown _withdraw) then { _withdraw ctrlShow false };
}
else
{
_deposit ctrlSetText "Deposit";
_deposit buttonSetAction "call mf_items_atm_deposit";
if (!ctrlShown _withdraw) then { _withdraw ctrlShow true };
_depositall ctrlSetText "Deposit All";
_depositall buttonSetAction "call mf_items_atm_deposit";
if (!ctrlShown _withdraw) then { _withdraw ctrlShow true };
};
};
call mf_items_atm_refresh_amounts;
init.sqf
// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
// @file Name: init.sqf
// @file Author: AgentRev, MercifulFate
private ["_path", "_condition", "_action"];
_path = "client\items\atm";
mf_items_atm_can_access = [_path, "can_access.sqf"] call mf_compile;
mf_items_atm_access = [_path, "access.sqf"] call mf_compile;
mf_items_atm_refresh = [_path, "refresh.sqf"] call mf_compile;
mf_items_atm_refresh_amounts = [_path, "refresh_amounts.sqf"] call mf_compile;
mf_items_atm_select_account = [_path, "select_account.sqf"] call mf_compile;
mf_items_atm_deposit = [_path, "deposit.sqf"] call mf_compile;
mf_items_atm_deposit_all = [_path, "depositall.sqf"] call mf_compile;
mf_items_atm_withdraw = [_path, "withdraw.sqf"] call mf_compile;
mf_items_atm_transfer = [_path, "transfer.sqf"] call mf_compile;
mf_items_atm_add_bounty = [_path, "add_bounty.sqf"] call mf_compile;
mf_items_atm_select_bounty = [_path, "select_bounty.sqf"] call mf_compile;
mf_items_atm_nearest =
{
private _target = cursorObject;
if ((str _target) find ": atm_" == -1 && {{_target isKindOf _x} count ["Land_Atm_01_F","Land_Atm_02_F"] == 0}) exitWith { objNull };
if (!(_target getVariable ["A3W_atmEditorPlaced", false]) && ["A3W_atmEditorPlacedOnly"] call isConfigOn) exitWith { objNull };
_target
} call mf_compile;
_condition = "call mf_items_atm_can_access == ''";
_action = ["<img image='client\icons\suatmm_icon.paa'/> Access ATM", mf_items_atm_access, [], 10, true, true, "", _condition];
["atm-access", _action] call mf_player_actions_set;
I want to create a button to deposit everything in the character's hand