Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Switch player to friendly unit - By BobTheHunted
- // Heavily based on BIS_fnc_modulRemoteControl for Zeus unit control
- // nul = [player,unit] call BTH_fnc_UnitTakeControl;
- // player: Object - Original player unit.
- // unit:-- Object - Unit to switch to.
- // Example: nul = [player,bob] call BTH_fnc_UnitTakeControl;
- params [
- ['_caller',objNull,[objNull]],
- ['_unit',objNull,[objNull]]
- ];
- if (isNull _unit) exitWith {hint "No suitable unit found"};
- if (isPlayer _unit) exitWith {hint "You cannot control a player unit!"};
- if (!alive _unit) exitWith {hint "You cannot control a dead unit!"};
- if (side _caller != side _unit) exitWith {hint "You cannot control a unit that isn't on your side!"};
- [_caller,_unit] spawn {
- params [
- ['_caller',objNull,[objNull]],
- ['_unit',objNull,[objNull]]
- ];
- _vehicle = vehicle _unit;
- _vehicleRole = str assignedVehicleRole _unit;
- //--- Switch
- _caller remoteControl (driver _unit);
- if (cameraOn != _vehicle) then {
- _vehicle switchCamera cameraView;
- };
- _unit addAction [
- "<t color='#53BE5F'>Exit Unit Control</t>",
- {
- private _unit = (_this select 0);
- private _caller = (_this select 3);
- removeAllActions _unit;
- private _vehicle = vehicle _unit;
- private _vehicleRole = str assignedVehicleRole _unit;
- private _rating = rating _caller;
- _caller addRating (-rating _caller + _rating);
- objNull remoteControl _unit;
- sleep 0.01;
- _caller switchCamera cameraView;
- },
- _caller, -1, false, true, "", "true", 1.5
- ];
- _vehicle = vehicle _unit;
- _vehicleRole = str assignedVehicleRole _unit;
- _rating = rating _caller;
- _caller addRating (-rating _caller + _rating);
- waitUntil {!alive _unit || !alive _caller};
- removeAllActions _unit;
- objNull remoteControl _unit;
- sleep 0.01;
- _caller switchCamera cameraView;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement