diff --git a/Sources/epoch_code/compile/traders/EPOCH_takeCrypto.sqf b/Sources/epoch_code/compile/traders/EPOCH_takeCrypto.sqf index 6034a420..0490fbb2 100644 --- a/Sources/epoch_code/compile/traders/EPOCH_takeCrypto.sqf +++ b/Sources/epoch_code/compile/traders/EPOCH_takeCrypto.sqf @@ -1,17 +1,27 @@ //[[[cog import generate_private_arrays ]]] -private ["_getCrypto"]; +private ["_nearCrypto","_CryptoItems","_getCrypto","_addmoney"]; //[[[end]]] if !(isNil "EPOCH_takeCryptoLock") exitWith {}; EPOCH_takeCryptoLock = true; -if (!isNull _this) then { - _getCrypto = _this getVariable["Crypto", 0]; - if (_getCrypto > 0) then { - [player, Epoch_personalToken, _this] remoteExec ["EPOCH_server_takeCrypto",2]; - [format["You found %1 Crypto", _getCrypto], 5] call Epoch_message; - } else { - ["No Crypto found", 5] call Epoch_message; +_nearCrypto = (nearestobjects [player,[],5]) select {(_x getvariable ["Crypto",0]) > 0}; +_CryptoItems = []; +_getCrypto = 0; +{ + _addmoney = (_x getvariable ['Crypto',0]); + if (_addmoney > 0) then { + _CryptoItems pushback _x; }; + _getCrypto = _getCrypto + _addmoney; +} foreach _nearCrypto; + +if (_getCrypto > 0) then { + [player, Epoch_personalToken, _CryptoItems] remoteExec ["EPOCH_server_takeCrypto",2]; + [format['You found %1 Crypto', _getCrypto], 5] call Epoch_message; +} +else { + ['No Crypto found', 5] call Epoch_message; }; + [] spawn{ uiSleep 2; EPOCH_takeCryptoLock = nil; diff --git a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_target.hpp b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_target.hpp index e5368e79..384c97cb 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_target.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_target.hpp @@ -78,7 +78,7 @@ class tra_shop class player_takeCrypto { - condition = "dyna_isDeadPlayer || (dyna_cursorTarget getVariable [""Crypto"",0]) > 0"; + condition = "dyna_isDeadPlayer || !(((nearestobjects [player,[],5]) select {(_x getvariable ['Crypto',0]) > 0}) isEqualTo [])"; action = "dyna_cursorTarget call EPOCH_takeCrypto;"; icon = "x\addons\a3_epoch_code\Data\UI\buttons\krypto.paa"; tooltip = "Take Crypto"; diff --git a/Sources/epoch_server/compile/epoch_trading/EPOCH_server_takeCrypto.sqf b/Sources/epoch_server/compile/epoch_trading/EPOCH_server_takeCrypto.sqf index 3bffdcf9..30bdcb53 100644 --- a/Sources/epoch_server/compile/epoch_trading/EPOCH_server_takeCrypto.sqf +++ b/Sources/epoch_server/compile/epoch_trading/EPOCH_server_takeCrypto.sqf @@ -15,21 +15,21 @@ //[[[cog import generate_private_arrays ]]] private ["_getCrypto"]; //[[[end]]] -params ["_player",["_token","",[""]],"_object"]; +params ["_player",["_token","",[""]],["_CryptoItems",[]]]; if !([_player,_token] call EPOCH_server_getPToken) exitWith {}; -if (isNull _object) exitWith {}; -if (_player distance _object > 10) exitWith {}; -_getCrypto = _object getVariable["Crypto", 0]; -if (_getCrypto > 0) then { - // remove crypto from object - _object setVariable["Crypto", nil, true]; - if (_object getvariable ["RemoveOnTake",false]) then { - deletevehicle _object; +_getCrypto = 0; +{ + if (_player distance _x < 10) then { + _getCrypto = _getCrypto + (_x getVariable ["Crypto", 0]); + _x setVariable ["Crypto", nil, true]; + if (_x getvariable ["RemoveOnTake",false]) then { + deletevehicle _x; + }; }; - // send data back to player +} foreach _CryptoItems; +if (_getCrypto > 0) then { [_player,_getCrypto] call EPOCH_server_effectCrypto; - // debug and logging. - diag_log format["Epoch: ADMIN: %1 picked up %2 Crypto from object %3 with puid %4 at %5", getPlayerUID _player, _getCrypto, [_object, typeOf _object],_object getVariable['PUID', ''],getposATL _object]; -}; + diag_log format["Epoch: ADMIN: %1 picked up %2 Crypto at %3", getPlayerUID _player, _getCrypto, getposATL _player]; +}; \ No newline at end of file