diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index ae277bf4d2..5c66fe692c 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -70,6 +70,9 @@ if (isNil QGVAR(maxWeightCarryRun)) then { [QGVAR(startCarry), LINKFUNC(startCarryLocal)] call CBA_fnc_addEventHandler; [QGVAR(startDrag), LINKFUNC(startDragLocal)] call CBA_fnc_addEventHandler; +[QGVAR(setCarryable), LINKFUNC(setCarryable)] call CBA_fnc_addEventHandler; +[QGVAR(setDraggable), LINKFUNC(setDraggable)] call CBA_fnc_addEventHandler; + [QGVAR(carryingContainerClosed), { params ["_container", "_owner"]; TRACE_2("carryingContainerClosed EH",_container,_owner); diff --git a/addons/dragging/functions/fnc_setCarryable.sqf b/addons/dragging/functions/fnc_setCarryable.sqf index f20197769e..c9850d6f57 100644 --- a/addons/dragging/functions/fnc_setCarryable.sqf +++ b/addons/dragging/functions/fnc_setCarryable.sqf @@ -9,6 +9,7 @@ * 2: Position offset for attachTo command (default: [0, 1, 1]) * 3: Direction in degrees to rotate the object after attachTo (default: 0) * 4: Override weight limit (default: false) + * 5: Apply globally (default: false) * * Return Value: * None @@ -24,7 +25,8 @@ params [ ["_enableCarry", false, [false]], "_position", "_direction", - ["_ignoreWeightCarry", false, [false]] + ["_ignoreWeightCarry", false, [false]], + ["_global", false, [false]] ]; if (isNull _object) exitWith {}; @@ -37,6 +39,19 @@ if (!isNil "_direction" && {!(_direction isEqualType 0)}) exitWith { ERROR_2("setCarryable: Bad direction parameter [%1] for [%2], should be a number or nil",_direction,_object); }; +// Handle global here +if (_global) exitWith { + private _jipID = format [QGVAR(carrying_%1), hashValue _object]; + [QGVAR(setCarryable), [_object, _enableCarry, _position, _direction, _ignoreWeightCarry], _jipID] call CBA_fnc_globalEventJIP; + + // Remove from JIP queue if object is deleted + if !(_object getVariable [QGVAR(setCarryableRemoveJip), false]) then { + [_jipID, _object] call CBA_fnc_removeGlobalEventJIP; + + _object setVariable [QGVAR(setCarryableRemoveJip), true, true]; + }; +}; + if (isNil "_position") then { _position = _object getVariable [QGVAR(carryPosition), [0, 1, 1]]; }; diff --git a/addons/dragging/functions/fnc_setDraggable.sqf b/addons/dragging/functions/fnc_setDraggable.sqf index 34f7689e52..8ff6cecf35 100644 --- a/addons/dragging/functions/fnc_setDraggable.sqf +++ b/addons/dragging/functions/fnc_setDraggable.sqf @@ -9,6 +9,7 @@ * 2: Position offset for attachTo command (default: [0, 1.5, 0]) * 3: Direction in degrees to rotate the object after attachTo (default: 0) * 4: Override weight limit (default: false) + * 5: Apply globally (default: false) * * Return Value: * None @@ -24,7 +25,8 @@ params [ ["_enableDrag", false, [false]], "_position", "_direction", - ["_ignoreWeightDrag", false, [false]] + ["_ignoreWeightDrag", false, [false]], + ["_global", false, [false]] ]; if (isNull _object) exitWith {}; @@ -37,6 +39,19 @@ if (!isNil "_direction" && {!(_direction isEqualType 0)}) exitWith { ERROR_2("setDraggable: Bad direction parameter [%1] for [%2], should be a number or nil",_direction,_object); }; +// Handle global here +if (_global) exitWith { + private _jipID = format [QGVAR(dragging_%1), hashValue _object]; + [QGVAR(setDraggable), [_object, _enableDrag, _position, _direction, _ignoreWeightDrag], _jipID] call CBA_fnc_globalEventJIP; + + // Remove from JIP queue if object is deleted + if !(_object getVariable [QGVAR(setDraggableRemoveJip), false]) then { + [_jipID, _object] call CBA_fnc_removeGlobalEventJIP; + + _object setVariable [QGVAR(setDraggableRemoveJip), true, true]; + }; +}; + if (isNil "_position") then { _position = _object getVariable [QGVAR(dragPosition), [0, 1.5, 0]]; }; diff --git a/addons/interaction/dev/initReplaceTerrainCursorObject.sqf b/addons/interaction/dev/initReplaceTerrainCursorObject.sqf index a1708be423..3f71954acb 100644 --- a/addons/interaction/dev/initReplaceTerrainCursorObject.sqf +++ b/addons/interaction/dev/initReplaceTerrainCursorObject.sqf @@ -47,12 +47,12 @@ DFUNC(replaceTerrainModelsAdd) = { ) then { // wait while server replaces object, then init dragging on all clients [{ - if (typeOf cursorObject == "") exitwith {}; - [cursorObject, { - if !hasInterface exitWith {}; - [_this, true] call EFUNC(dragging,setDraggable); - [_this, true] call EFUNC(dragging,setCarryable); - }] remoteExec ["call", 0]; + private _object = cursorObject; + + if (isNull _object) exitwith {}; + + [_object, true, nil, nil, nil, true] call EFUNC(dragging,setCarryable); + [_object, true, nil, nil, nil, true] call EFUNC(dragging,setDraggable); }, [], 1] call CBA_fnc_waitAndExecute; }; true diff --git a/docs/wiki/framework/dragging-framework.md b/docs/wiki/framework/dragging-framework.md index 43a7c98ba4..da0be50da9 100644 --- a/docs/wiki/framework/dragging-framework.md +++ b/docs/wiki/framework/dragging-framework.md @@ -53,6 +53,7 @@ You will **not** be able to carry / drag objects that are too heavy, the mass is | 2 | Position to offset the object from player | Array | Optional (default: `[0, 1.5, 0]`) | | 3 | Direction in degree to rotate the object | Number | Optional (default: `0`) | | 4 | Ignore weight limitation for dragging | Boolean | Optional (default: `false`) | +| 5 | Apply changes globally | Boolean | Optional (default: `false`) | | **R** | None | None | Return value | #### 2.1.1 Example 1 @@ -63,7 +64,7 @@ You will **not** be able to carry / drag objects that are too heavy, the mass is |----| --------- | ----------- | | 0 | `foo` | My object | | 1 | `true` | Dragging is enabled | -| 2 | `[0,2,0]` | 0 meters sideways, 2 meters forward, 0 |meters upwards +| 2 | `[0,2,0]` | 0 meters sideways, 2 meters forward, 0 meters upwards | | 3 | `45` | Rotated by 45° | #### 2.1.2 Example 2 @@ -89,6 +90,7 @@ You will **not** be able to carry / drag objects that are too heavy, the mass is | 2 | Position to offset the object from player | Array | Optional (default: `[0, 1, 1]`) | | 3 | Direction in degree to rotate the object | Number | Optional (default: `0`) | | 4 | Ignore weight limitation for carrying | Boolean | Optional (default: `false`) | +| 5 | Apply changes globally | Boolean | Optional (default: `false`) | | **R** | None | None | Return value | #### 2.2.1 Example