Arma 3
Conda Economy [DEV]
Condasoft  [developer] 27 Jan @ 6:33am
Custom Functions
Here's an example of how users can create their own functions to interact with the money system: (THIS IS FOR DEVELOPERS NORMAL USERS OF THE SCRIPT DON'T NEED TO BE BOTHERED BY THIS SECTION).

Accessing Player Money
Get Player's UID:

private _playerUID = getPlayerUID player;
Accessing Bank and Cash Money:
sqf
private _bankMoney = profileNamespace getVariable [_playerUID + "_bankMoney", 0];
private _cashMoney = profileNamespace getVariable [_playerUID + "_cashMoney", 0];

Creating Custom Functions
Here are some examples of custom functions:

1. Function to Check Balance

fnc_checkBalance = {
params [["_player", player]];
private _playerUID = getPlayerUID _player;
private _bankMoney = profileNamespace getVariable [_playerUID + "_bankMoney", 0];
private _cashMoney = profileNamespace getVariable [_playerUID + "_cashMoney", 0];
systemChat format ["Bank: $%1, Cash: $%2", _bankMoney, _cashMoney];
};

2. Function to Deposit Money to Bank

fnc_depositMoney = {
params [["_player", player], ["_amount", 0]];
private _playerUID = getPlayerUID _player;
private _cashMoney = profileNamespace getVariable [_playerUID + "_cashMoney", 0];
private _bankMoney = profileNamespace getVariable [_playerUID + "_bankMoney", 0];

if (_cashMoney >= _amount) then {
_cashMoney = _cashMoney - _amount;
_bankMoney = _bankMoney + _amount;
profileNamespace setVariable [_playerUID + "_cashMoney", _cashMoney];
profileNamespace setVariable [_playerUID + "_bankMoney", _bankMoney];
saveProfileNamespace;
systemChat format ["Deposited $%1. New Balance: Bank - $%2, Cash - $%3", _amount, _bankMoney, _cashMoney];
} else {
systemChat "Not enough cash to deposit!";
};
};

3. Function to Withdraw Money from Bank

fnc_withdrawMoney = {
params [["_player", player], ["_amount", 0]];
private _playerUID = getPlayerUID _player;
private _bankMoney = profileNamespace getVariable [_playerUID + "_bankMoney", 0];
private _cashMoney = profileNamespace getVariable [_playerUID + "_cashMoney", 0];

if (_bankMoney >= _amount) then {
_bankMoney = _bankMoney - _amount;
_cashMoney = _cashMoney + _amount;
profileNamespace setVariable [_playerUID + "_bankMoney", _bankMoney];
profileNamespace setVariable [_playerUID + "_cashMoney", _cashMoney];
saveProfileNamespace;
systemChat format ["Withdrawn $%1. New Balance: Bank - $%2, Cash - $%3", _amount, _bankMoney, _cashMoney];
} else {
systemChat "Not enough money in the bank!";
};
};

Usage in Game
To use these functions, you would call them like this:

// Check balance
[] call fnc_checkBalance;

// Deposit 1000 cash into the bank
[player, 1000] call fnc_depositMoney;

// Withdraw 500 from the bank
[player, 500] call fnc_withdrawMoney;
Last edited by Condasoft; 27 Jan @ 6:38am
< >
Showing 1-1 of 1 comments
Condasoft  [developer] 27 Jan @ 6:35am 
^ Just an example, pasting it onto steam has messed up the indents so you could ask a GPT to fix the indents for you and remove the comments, init doesn't like comments.
Last edited by Condasoft; 27 Jan @ 6:35am
< >
Showing 1-1 of 1 comments
Per page: 1530 50