Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize pickupAction function #654

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions life_server/Functions/Actions/fn_pickupAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private _target = param [0, objNull, [objNull]];
params [
["_target", objNull, [objNull]]
];


if (!isRemoteExecuted) exitWith {};
if (isNull _obj) exitWith {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still _obj

private _item = _target getVariable "item";
if (isNil "_item") exitWith {};

if !(_obj getVariable ["inUse",false]) exitWith {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would rather actually exit if its in use than executing code when it isnt

Suggested change
if !(_obj getVariable ["inUse",false]) exitWith {
if (_obj getVariable ["inUse",false]) exitWith {};

_target setVariable ["inUse",true,true];

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 {
Copy link
Contributor

@blackfisch blackfisch May 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for "item" variable to be nil -> could theoretically happen. Better safe than sorry

_target remoteExecCall ["life_fnc_pickupMoney", remoteExecutedOwner];
} else {
_obj remoteExecCall ["life_fnc_pickupItem",_client];
_target remoteExecCall ["life_fnc_pickupItem", remoteExecutedOwner];
};
};
};