LeventHAN

fn_restrainAction.sqPolisf

Sep 10th, 2018
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.87 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2.  
  3. private ["_cop","_player","_vehicle"];
  4. _cop = [_this,0,objNull,[objNull]] call BIS_fnc_param;
  5. _player = player;
  6. _vehicle = vehicle player;
  7. if (isNull _cop) exitWith {};
  8.  
  9. [] spawn {
  10.     private "_time";
  11.     for "_i" from 0 to 1 step 0 do {
  12.         _time = time;
  13.         waitUntil {(time - _time) > (5 * 60)};
  14.  
  15.         if (!(player getVariable ["restrained",false])) exitWith {};
  16.         if (!([west,getPos player,30] call life_fnc_nearUnits) && (player getVariable ["restrained",false]) && isNull objectParent player) exitWith {
  17.             player setVariable ["restrained",false,true];
  18.             player setVariable ["Escorting",false,true];
  19.             player setVariable ["transporting",false,true];
  20.             detach player;
  21.             titleText[localize "STR_Cop_ExcessiveRestrain","PLAIN"];
  22.         };
  23.     };
  24. };
  25.  
  26. titleText[format [localize "STR_Cop_Restrained",_cop getVariable ["realname",name _cop]],"PLAIN"];
  27.  
  28. life_disable_getIn = true;
  29. life_disable_getOut = false;
  30.  
  31. while {player getVariable  "restrained"} do {
  32.     if (isNull objectParent player) then {
  33.         player playMove "AmovPercMstpSnonWnonDnon_Ease";
  34.     };
  35.  
  36.     _state = vehicle player;
  37.     waitUntil {animationState player != "AmovPercMstpSnonWnonDnon_Ease" || !(player getVariable "restrained") || vehicle player != _state};
  38.  
  39.     if (!alive player) exitWith {
  40.         player setVariable ["restrained",false,true];
  41.         player setVariable ["Escorting",false,true];
  42.         player setVariable ["transporting",false,true];
  43.         detach _player;
  44.     };
  45.  
  46.     if (!alive _cop) then {
  47.         player setVariable ["Escorting",false,true];
  48.         detach player;
  49.     };
  50.  
  51.     if (!(isNull objectParent player) && life_disable_getIn) then {
  52.         player action["eject",vehicle player];
  53.     };
  54.  
  55.     if (!(isNull objectParent player) && !(vehicle player isEqualTo _vehicle)) then {
  56.         _vehicle = vehicle player;
  57.     };
  58.  
  59.     if (isNull objectParent player && life_disable_getOut) then {
  60.         player moveInCargo _vehicle;
  61.     };
  62.  
  63.     if (!(isNull objectParent player) && life_disable_getOut && (driver (vehicle player) isEqualTo player)) then {
  64.         player action["eject",vehicle player];
  65.         player moveInCargo _vehicle;
  66.     };
  67.  
  68.     if (!(isNull objectParent player) && life_disable_getOut) then {
  69.         _turrets = [[-1]] + allTurrets _vehicle;
  70.         {
  71.             if (_vehicle turretUnit [_x select 0] isEqualTo player) then {
  72.                 player action["eject",vehicle player];
  73.                 sleep 1;
  74.                 player moveInCargo _vehicle;
  75.             };
  76.         }forEach _turrets;
  77.     };
  78. };
  79.  
  80. if (alive player) then {
  81.     player switchMove "AmovPercMstpSlowWrflDnon_SaluteIn";
  82.     player setVariable ["Escorting",false,true];
  83.     player setVariable ["transporting",false,true];
  84.     detach player;
  85. };
Advertisement