LeventHAN

dsicord

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