Skip to content

Instantly share code, notes, and snippets.

@bosoy
Created December 10, 2017 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bosoy/0bac431c5df8897e2fcc7fea7e27c2f1 to your computer and use it in GitHub Desktop.
Save bosoy/0bac431c5df8897e2fcc7fea7e27c2f1 to your computer and use it in GitHub Desktop.
/*
Function: ACE_fnc_deleteLoadCargo
Description:
A function used to delete cargo from a vehicle.
Parameters:
_veh - Vehicle to load cargo into. (Must exist) [Object]
_cargo - Cargo object to load. (Must exist) [Array of one or more objects]
Returns:
nothing
Example:
(begin example)
[myTruck,[myCrate1, myCrate2]] call ACE_fnc_deleteLoadCargo; // delete myCrate1, myCrate2 cargo
or
[myTruck] call ACE_fnc_deleteLoadCargo; //delete all cargo
(end)
Author:
ArseniyK, Dimon UA
*/
private["_veh","_cargo", "_currentcontent", "_item","_canload"];
_veh = _this select 0;
_cargo = _this select 1;
_canload = [_veh] call ACE_fnc_canLoadCargo; // проверяем авто на профпригодность
if _canload then
{
sleep 5;
_currentcontent = _veh getVariable "ace_sys_cargo_content";
if (!isNil "_cargo" && {count _cargo > 0} && {!isNil "_currentcontent"}) then
{
{
_item=_x;
{
if (typeOf _x == _item) then
{
_currentcontent set [_forEachIndex, objNull];
_currentcontent = _currentcontent - [objNull];
_veh setVariable ["ace_sys_cargo_content", _currentcontent, true];
};
}foreach _currentcontent;
} foreach _cargo;
}else{
_veh setVariable ["ace_sys_cargo_content",[],true];
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment