Refactor createCrate

This commit is contained in:
Wyqer 2019-12-03 22:33:56 +01:00
parent 68f8c5205a
commit d00a2709a3
No known key found for this signature in database
GPG Key ID: D7E2F8BD7F1E48FA
1 changed files with 12 additions and 5 deletions

View File

@ -16,14 +16,20 @@
Returns:
Created crate [OBJECT]
*/
// TODO
params [["_resource", KP_liberation_supply_crate],["_amount", 100],["_pos", getPos player]];
params [
["_resource", KP_liberation_supply_crate, [""]],
["_amount", 100, [0]],
["_pos", getPos player, [[]], [2, 3]]
];
// Check if resource is valid
if !(_resource in KP_liberation_crates) exitWith {
private _text = format ["[KP LIBERATION] [ERROR] F_kp_createCrate.sqf -> invalid _resource: %1", _resource];
_text remoteExec ["diag_log",2];
["Invalid resource param given: %1", _resource] call BIS_fnc_error;
objNull
};
// Create crate
private _crate = _resource createVehicle _pos;
_crate setMass 500;
_crate setVariable ["KP_liberation_crate_value", _amount, true];
@ -32,7 +38,8 @@ clearMagazineCargoGlobal _crate;
clearBackpackCargoGlobal _crate;
clearItemCargoGlobal _crate;
if(KP_liberation_ace) then {[_crate, true, [0, 1.5, 0], 0] remoteExec ["ace_dragging_fnc_setCarryable"];};
// Add ACE carry functionality
if (KP_liberation_ace) then {[_crate, true, [0, 1.5, 0], 0] remoteExec ["ace_dragging_fnc_setCarryable"];};
// Process KP object init
[_crate] call KPLIB_fnc_addObjectInit;