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

Added alternative function setCargo that replace cargo and addCargo that append to the cargo container #1165

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Removed code duplication
  • Loading branch information
AndreasBrostrom committed Apr 4, 2024
commit b9ceeece7b4ab38ef8fe9a614a9a65b8c4cdf199
4 changes: 1 addition & 3 deletions cScripts/functions/logistics/fn_addCargo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
* Example:
* [MyCrate, [["ACE_EarPlugs", 60]]] call cScripts_fnc_addCargo;
* [MyTruck, [["ACE_personalAidKit", 8], ["ACE_tourniquet", 10]]] call cScripts_fnc_addCargo;
* [MyTruck, [["ACE_personalAidKit", 8], ["ACE_tourniquet", 10]], "myCrate", false] call cScripts_fnc_addCargo;
*
* Public: Yes
*/

params [
["_vehicle", objNull, [objNull]],
["_inventory", [], [[]]],
["_crateName", "", [""]]
["_inventory", [], [[]]]
];

if ( count _inventory < 1 ) exitWith {};
Expand Down
18 changes: 2 additions & 16 deletions cScripts/functions/logistics/fn_setCargo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,18 @@
* Example:
* [MyCrate, [["ACE_EarPlugs", 60]]] call cScripts_fnc_setCargo;
* [MyTruck, [["ACE_personalAidKit", 8], ["ACE_tourniquet", 10]]] call cScripts_fnc_setCargo;
* [MyTruck, [["ACE_personalAidKit", 8], ["ACE_tourniquet", 10]], "myCrate", false] call cScripts_fnc_setCargo;
*
* Public: Yes
*/

params [
["_vehicle", objNull, [objNull]],
["_inventory", [], [[]]],
["_crateName", "", [""]]
["_inventory", [], [[]]]
];

clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;
clearItemCargoGlobal _vehicle;
clearBackpackCargoGlobal _vehicle;

if ( count _inventory < 1 ) exitWith {};

{
if !(_x isEqualTypeArray ["",0]) then {
SHOW_WARNING_1("addCargo","Item not added because %1 does not contain the proper format. Must be [STRING, SCALAR].", _x);
continue;
};

_x params [["_item", "", [""]], ["_amount", 0, [0]]];
if (_item call FUNC(checkItemValidity)) then {
_vehicle addItemCargoGlobal [_item, _amount];
};
} forEach _inventory;
[_vehicle, _inventory] call FUNC(addCargo);