Jump to content
  • 0

How to properly manipulate player cash (wallet) & bank account from the server-side


mgm

Question

the other question I submitted earlier was getting a quick & dirty hack to manipulate cash (wallet) contents for dev purposes and it is working.
however as raymix mentioned this is not he correct way to manipulate cash for "production" systems, as server simply doesn't save modified cash amount to the DB.

I tested this,  I inject 250K cash to my character and I can purchase services for test purposes however as soon as I log out & back in, wallet is back to original amount (zero).

 

so please what are the correct functions to add/remove money to wallet AND the also manipulate players bank account?

would be great if you give tested & working examples from your scripts.

 

thanks

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 1
On 5/6/2016 at 5:21 AM, vbawol said:


Check this function I have just added to experimental,  it basically contains everything that needs to be done to effect crypto server side. and as of 0.3.9.0450 it will be a function.

I went with this option, working fine. Thanks a lot.

Link to comment
Share on other sites

  • 0

Halv provided a working solution for wallet transactions  in his Black Market trader scripts (He-Man provided the modification for 0.3.8). Two that are relevent are, HALV_takegive_crypto_init:

/*
	HALV_takegive_crypto_init.sqf
	by Halv
	
	Copyright (C) 2015  Halvhjearne & Suppe
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
	Contact : [email protected]
*/

if(isServer)then{
	diag_log "[HSBlackmarket] Server: loading 'HALV_takegive_crypto.sqf'";
	HALV_server_takegive_crypto = compileFinal preprocessFileLineNumbers "trader\HALV_takegive_crypto.sqf";
	diag_log "[HSBlackmarket] Server: loading 'HALV_takegive' PVEvent";
	"HALV_takegive" addPublicVariableEventHandler {(_this select 1) call HALV_server_takegive_crypto};
};

if(hasInterface)then{
	isHalvTradeEnabled = true;
};

and, HALV_takegive_crypto.sqf:

/*
	HALV_takegive_crypto.sqf
	by Halv
	
	Copyright (C) 2015  Halvhjearne & Suppe
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
	Contact : [email protected]
*/

_player = _this select 0;
_nr = _this select 1;
_cIndex=EPOCH_customVars find 'Crypto';
//_vars = _player getVariable['VARS',[]+EPOCH_defaultVars_SEPXVar];
_vars = _player getVariable['VARS', call EPOCH_defaultVars_SEPXVar]; // Changed for Epoch 0.3.8
_curcrypt = _vars select _cIndex;
_newcrypt = _curcrypt+_nr;
//[['effectCrypto',_newcrypt],(owner _player)]call EPOCH_sendPublicVariableClient;
_newcrypt remoteExec ['EPOCH_effectCrypto',(owner _player)]; // Changed for Epoch 0.3.8
_vars set[_cIndex,_newcrypt];
_player setVariable["VARS",_vars];

This is well tested and in production in 0.3.8.

Link to comment
Share on other sites

  • 0

For bank transfers from the client, here's the Epoch client code for ATM transactions (MISSION/epoch_code/compile/traders/EPOCH_startBankTransfer.sqf:

if (isNull(findDisplay -13)) exitWith{};
// perform wait while menu is still open

if (isNil "EPOCH_bankTransferActive") then {
	EPOCH_bankTransferActive = true;

	ctrlEnable[1600, false];

	[] spawn {
		private ["_transferTarget","_progress","_sleep","_deposit","_withdraw","_transfer","_totalTransfer"];
		
		ctrlSetText[1004,"Transfer started, please wait."];

		_deposit = parseNumber(ctrlText 1401) min EPOCH_playerCrypto;
		_withdraw = parseNumber(ctrlText 1402) min EPOCH_bankBalance;
		_transfer = parseNumber(ctrlText 1400) min EPOCH_bankBalance;

		_totalTransfer = (_deposit + _withdraw) + _transfer;
		_progress = 0;

		uiSleep 1;

		_transferTarget = "";
		if (_transfer > 0) then {
			_transferTarget = lbData[21500, (lbCurSel 21500)];
		};

		if (_deposit > 0 || _withdraw > 0 || (_transfer > 0 && _transferTarget != "")) then {

			_sleep = ((_totalTransfer * 0.0006) min 1.2) max 0.06;
			for "_i" from 0 to 100 do {
				if (isNull(findDisplay -13)) exitWith{};
				_progress = _progress + 1;
				if (_progress > 100) exitWith{};
				ctrlSetText[1200, format["\x\addons\a3_epoch_code\Data\UI\loading_bar_%1.paa", _progress]];
				uiSleep _sleep;
			};

			if (_progress >= 100) then {
				// if player waited the full time then send upload
				[player, [_deposit, _withdraw, [_transfer, _transferTarget]], Epoch_personalToken] remoteExec ["EPOCH_server_storeCrypto",2];
				ctrlSetText[1004, "Transfer complete."];
				uiSleep 1;
				closeDialog 0;
			}
			else {
				ctrlSetText[1004, "Transfer failed."];
			};
		};
		EPOCH_bankTransferActive = nil;
		ctrlEnable[1600, true];
	};
};

 

Link to comment
Share on other sites

  • -1

And for comparison with the Black Market trader code, here's Epoch's client code for picking up Krypto (MISSION/epoch_code/compile/trader/EPOCH_takeCrypto.sqf:

private["_getCrypto"];
if !(isNil "EPOCH_takeCryptoLock") exitWith {};
EPOCH_takeCryptoLock = true;
if (!isNull _this) then {
	if ((typeof _this) == "Land_MPS_EPOCH") then {
		_getCrypto = _this getVariable["Crypto", 0];
		[player, Epoch_personalToken, _this] remoteExec ["EPOCH_server_takeCrypto",2];
		[format["<t size='1.6' color='#99ffffff'>You found %1 Krypto.</t>", _getCrypto], 5] call Epoch_dynamicText;
	};
};
[] spawn{
	uiSleep 2;
	EPOCH_takeCryptoLock = nil;
};

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...