From d77e542f73162199c7c3f8fa26d5ae0ce76c4a37 Mon Sep 17 00:00:00 2001 From: vbawol Date: Thu, 5 May 2016 23:09:38 -0500 Subject: [PATCH] make single function to effect crypto server side --- .../EPOCH_server_effectCrypto.sqf | 44 +++++++++++++++++++ Sources/epoch_server/config.cpp | 1 + 2 files changed, 45 insertions(+) create mode 100644 Sources/epoch_server/compile/epoch_trading/EPOCH_server_effectCrypto.sqf diff --git a/Sources/epoch_server/compile/epoch_trading/EPOCH_server_effectCrypto.sqf b/Sources/epoch_server/compile/epoch_trading/EPOCH_server_effectCrypto.sqf new file mode 100644 index 00000000..1c451ab6 --- /dev/null +++ b/Sources/epoch_server/compile/epoch_trading/EPOCH_server_effectCrypto.sqf @@ -0,0 +1,44 @@ +/* + Author: Aaron Clark - EpochMod.com + + Contributors: + + Description: + Epoch Mod - Server side effect crypto main function + + Licence: + Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike + + Github: + https://github.com/EpochModTeam/Epoch/tree/master/Sources/epoch_server/compile/epoch_trading/EPOCH_server_effectCrypto.sqf + + Example: + [_player,100] call EPOCH_server_effectCrypto; // adds 100 + [_player,-100] call EPOCH_server_effectCrypto; // removes 100 + + Parameter(s): + _this select 0: OBJECT - player + _this select 1: NUMBER - amount to add to existing crypto + Returns: + MIXED +*/ +private ["_cIndex","_vars","_current_crypto"]; +params [["_player",objNull,[objNull]],["_crypto",0,[0]]]; +if (!isNull _player && isPlayer _player) then { + // get index of custom variable + _cIndex = EPOCH_customVars find "Crypto"; + // get custom variables + _vars = _player getVariable["VARS", call EPOCH_defaultVars_SEPXVar]; + // select current value + _current_crypto = _vars select _cIndex; + // get min and max limits for selected custom variable + (EPOCH_customVarLimits select _cIndex) params ["_playerCryptoLimitMax","_playerCryptoLimitMin"]; + // add input number to existing variable while keeping it within min and max range. + _current_crypto = ((_current_crypto + _crypto) min _playerCryptoLimitMax) max _playerCryptoLimitMin; + // send final value back to the player + _current_crypto remoteExec ['EPOCH_effectCrypto',_player]; + // set final variable + _vars set[_cIndex, _current_crypto]; + // save modified custom variables array + _player setVariable["VARS", _vars]; +}; diff --git a/Sources/epoch_server/config.cpp b/Sources/epoch_server/config.cpp index 89309c60..438cda74 100644 --- a/Sources/epoch_server/config.cpp +++ b/Sources/epoch_server/config.cpp @@ -85,6 +85,7 @@ class CfgServerFunctions class server_spawnTraders {}; }; class epoch_trading { + class server_effectCrypto {}; class server_makeTrade {}; class server_tradeRequest {}; class server_makeNPCTrade {};