From 7857e6f4beb7702b3a2715d8fe8a9fbdeafd7093 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Fri, 1 May 2020 13:53:15 +0200 Subject: [PATCH 1/5] Modernize pickupAction function --- .../Functions/Actions/fn_pickupAction.sqf | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/life_server/Functions/Actions/fn_pickupAction.sqf b/life_server/Functions/Actions/fn_pickupAction.sqf index 592fa3192..54e214ad0 100644 --- a/life_server/Functions/Actions/fn_pickupAction.sqf +++ b/life_server/Functions/Actions/fn_pickupAction.sqf @@ -2,23 +2,22 @@ /* File: fn_pickupAction.sqf Author: Bryan "Tonic" Boardwine - Description: Validates that the cash is not a lie */ -params [ - ["_obj",objNull,[objNull]], - ["_client",objNull,[objNull]], - ["_cash",false,[true]] -]; +private _target = param [0, objNull, [objNull]]; + +if (!isRemoteExecuted) exitWith { ["Not remote executed"] call BIS_fnc_error }; +if (isNull _obj) exitWith { ["Target object is NULL"] call BIS_fnc_error }; -if (isNull _obj || {isNull _client}) exitWith {systemChat "Obj or client is null?";}; //No. if (!(_obj getVariable ["inUse",false])) exitWith { - _client = owner _client; _obj setVariable ["inUse",true,true]; - if (_cash) then { - _obj remoteExecCall ["life_fnc_pickupMoney",_client]; + + if (_target getVariable "item" select 0 isEqualTo "cash") then { + _obj remoteExecCall ["life_fnc_pickupMoney", remoteExecutedOwner]; } else { - _obj remoteExecCall ["life_fnc_pickupItem",_client]; + _obj remoteExecCall ["life_fnc_pickupItem", remoteExecutedOwner]; }; -}; \ No newline at end of file +} else { + [ "Attempt to pick up money twice!" ] call BIS_fnc_error; +}; From 15b49ce15ffc03063873f9269ac011f096a2bd19 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Fri, 1 May 2020 14:00:08 +0200 Subject: [PATCH 2/5] Switch single tab to 4 spaces --- life_server/Functions/Actions/fn_pickupAction.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/life_server/Functions/Actions/fn_pickupAction.sqf b/life_server/Functions/Actions/fn_pickupAction.sqf index 54e214ad0..3f62ddba9 100644 --- a/life_server/Functions/Actions/fn_pickupAction.sqf +++ b/life_server/Functions/Actions/fn_pickupAction.sqf @@ -19,5 +19,5 @@ if (!(_obj getVariable ["inUse",false])) exitWith { _obj remoteExecCall ["life_fnc_pickupItem", remoteExecutedOwner]; }; } else { - [ "Attempt to pick up money twice!" ] call BIS_fnc_error; + [ "Attempt to pick up money twice!" ] call BIS_fnc_error; }; From 685ff245f92cc5b2d65eae05aebf99be86eb12ea Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Fri, 1 May 2020 14:12:21 +0200 Subject: [PATCH 3/5] Remove logging, check for "items" to be an array and fix oversight --- life_server/Functions/Actions/fn_pickupAction.sqf | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/life_server/Functions/Actions/fn_pickupAction.sqf b/life_server/Functions/Actions/fn_pickupAction.sqf index 3f62ddba9..a9d1c9493 100644 --- a/life_server/Functions/Actions/fn_pickupAction.sqf +++ b/life_server/Functions/Actions/fn_pickupAction.sqf @@ -7,17 +7,16 @@ */ private _target = param [0, objNull, [objNull]]; -if (!isRemoteExecuted) exitWith { ["Not remote executed"] call BIS_fnc_error }; -if (isNull _obj) exitWith { ["Target object is NULL"] call BIS_fnc_error }; +if (!isRemoteExecuted) exitWith {}; +if (isNull _obj) exitWith {}; +if (!(_target getVariable ["item", false]) isEqualType []) exitWith {}; if (!(_obj getVariable ["inUse",false])) exitWith { - _obj setVariable ["inUse",true,true]; + _target setVariable ["inUse",true,true]; if (_target getVariable "item" select 0 isEqualTo "cash") then { - _obj remoteExecCall ["life_fnc_pickupMoney", remoteExecutedOwner]; + _target remoteExecCall ["life_fnc_pickupMoney", remoteExecutedOwner]; } else { - _obj remoteExecCall ["life_fnc_pickupItem", remoteExecutedOwner]; + _target remoteExecCall ["life_fnc_pickupItem", remoteExecutedOwner]; }; -} else { - [ "Attempt to pick up money twice!" ] call BIS_fnc_error; }; From 08d1ac006ed8e78ffe5ab69880442f360f8480cd Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Fri, 1 May 2020 14:25:47 +0200 Subject: [PATCH 4/5] Update life_server/Functions/Actions/fn_pickupAction.sqf Co-authored-by: Blackfisch --- life_server/Functions/Actions/fn_pickupAction.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/life_server/Functions/Actions/fn_pickupAction.sqf b/life_server/Functions/Actions/fn_pickupAction.sqf index a9d1c9493..fa6a87080 100644 --- a/life_server/Functions/Actions/fn_pickupAction.sqf +++ b/life_server/Functions/Actions/fn_pickupAction.sqf @@ -11,7 +11,7 @@ if (!isRemoteExecuted) exitWith {}; if (isNull _obj) exitWith {}; if (!(_target getVariable ["item", false]) isEqualType []) exitWith {}; -if (!(_obj getVariable ["inUse",false])) exitWith { +if !(_obj getVariable ["inUse",false]) exitWith { _target setVariable ["inUse",true,true]; if (_target getVariable "item" select 0 isEqualTo "cash") then { From 7cf3f155a45667d668b9ab835a110726943cedf3 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Fri, 1 May 2020 14:32:44 +0200 Subject: [PATCH 5/5] Update life_server/Functions/Actions/fn_pickupAction.sqf Co-authored-by: Blackfisch --- life_server/Functions/Actions/fn_pickupAction.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/life_server/Functions/Actions/fn_pickupAction.sqf b/life_server/Functions/Actions/fn_pickupAction.sqf index fa6a87080..183d9d488 100644 --- a/life_server/Functions/Actions/fn_pickupAction.sqf +++ b/life_server/Functions/Actions/fn_pickupAction.sqf @@ -9,7 +9,8 @@ private _target = param [0, objNull, [objNull]]; if (!isRemoteExecuted) exitWith {}; if (isNull _obj) exitWith {}; -if (!(_target getVariable ["item", false]) isEqualType []) exitWith {}; +private _item = _target getVariable "item"; +if (isNil "_item") exitWith {}; if !(_obj getVariable ["inUse",false]) exitWith { _target setVariable ["inUse",true,true];