|
| 1 | +/* ---------------------------------------------------------------------------- |
| 2 | +Function: bnb_e_sling_mask_fnc_addSlungMask |
| 3 | +
|
| 4 | +Description: |
| 5 | + Adds a slung mask to the given unit. |
| 6 | +
|
| 7 | +Parameters: |
| 8 | + 0: _unit <OBJECT> |
| 9 | + 1: _maskClass <OBJECT> |
| 10 | +
|
| 11 | +Returns: |
| 12 | + Nothing |
| 13 | +
|
| 14 | +Examples: |
| 15 | + [player, "H_HelmetB_desert"] call bnb_e_sling_mask_fnc_addSlungMask; |
| 16 | +
|
| 17 | +Author: |
| 18 | + DerZade, Arend |
| 19 | +---------------------------------------------------------------------------- */ |
| 20 | +params ["_unit", "_maskClass"]; |
| 21 | + |
| 22 | +//remove old helmet if unit has already a slung helmet |
| 23 | +if !(([_unit] call GRAD_slingHelmet_fnc_getSlungHelmet) isEqualTo "") then { |
| 24 | + [_unit] call GRAD_slingHelmet_fnc_removeSlungHelmet; |
| 25 | +}; |
| 26 | + |
| 27 | +//create weaponholder |
| 28 | +private _weaponHolder = createVehicle ["GRAD_slingHelmet_WeaponHolder", getPos _unit, [], 0, "CAN_COLLIDE"]; |
| 29 | +_weaponHolder addItemCargoGlobal [_maskClass, 1]; |
| 30 | + |
| 31 | +//add EHs to unit |
| 32 | +private _getInID = _unit addEventHandler ["GetInMan",GRAD_slingHelmet_fnc_EHGetIn]; |
| 33 | +private _getOutID = _unit addEventHandler ["GetOutMan",bnb_e_sling_mask_fnc_EHGetOut]; |
| 34 | +private _killedID = _unit addEventHandler ["Killed",GRAD_slingHelmet_fnc_EHKilled]; |
| 35 | + |
| 36 | +_unit setVariable ["GRAD_slingHelmet_variable",[_maskClass, _weaponHolder, [_getInID,_getOutID,_killedID]], true]; |
| 37 | + |
| 38 | +//add HandleDisconnect-EH on server if not done yet |
| 39 | +if !(missionNamespace getVariable ["GRAD_slingHelmet_HDCEHadded",false]) then { |
| 40 | + ["HandleDisconnect", GRAD_slingHelmet_fnc_EHHandleDisconnect] remoteExec ["addMissionEventHandler", 2]; |
| 41 | + GRAD_slingHelmet_HDCEHadded = true; |
| 42 | + publicVariable "GRAD_slingHelmet_HDCEHadded"; |
| 43 | +}; |
| 44 | + |
| 45 | +//execute vehicle shit |
| 46 | +if !(vehicle _unit isEqualTo _unit) then { |
| 47 | + [_unit, "", vehicle _unit] call GRAD_slingHelmet_fnc_EHGetIn; |
| 48 | +} else { |
| 49 | + [_unit, "", objNull] call bnb_e_sling_mask_fnc_EHGetOut; |
| 50 | +}; |
0 commit comments