Take Crypto tweak

This commit is contained in:
He-Man 2019-03-21 20:32:15 +01:00
parent b0ae47ffe7
commit 84d071f1fd
3 changed files with 32 additions and 22 deletions

View File

@ -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;

View File

@ -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";

View File

@ -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];
};