SHARE
TWEET

Untitled

a guest Jul 6th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "..\..\script_macros.hpp"
  2. /*
  3.     File: fn_escInterupt.sqf
  4.     Author: Bryan "Tonic" Boardwine
  5.  
  6.     Description:
  7.     Monitors when the ESC menu is pulled up and blocks off
  8.     certain controls when conditions meet.
  9. */
  10. private["_abortButton","_respawnButton","_fieldManual","_escSync","_canUseControls"];
  11. disableSerialization;
  12.  
  13. _escSync = {
  14.     private["_abortButton","_thread","_syncManager"];
  15.     disableSerialization;
  16.  
  17.     _syncManager = {
  18.         disableSerialization;
  19.         private["_abortButton","_timeStamp"];
  20.         _abortButton = CONTROL(49,104);
  21.         _timeStamp = time + 10;
  22.  
  23.         waitUntil {
  24.             _abortButton ctrlSetText format[localize "STR_NOTF_AbortESC",[(_timeStamp - time),"SS.MS"] call BIS_fnc_secondsToString];
  25.             _abortButton ctrlCommit 0;
  26.             round(_timeStamp - time) <= 0 || isNull (findDisplay 49)
  27.         };
  28.  
  29.         _abortButton ctrlSetText localize "STR_DISP_INT_ABORT";
  30.         _abortButton ctrlCommit 0;
  31.     };
  32.  
  33.     _abortButton = CONTROL(49,104);
  34.  
  35.     if (_this) then {
  36.         _thread = [] spawn _syncManager;
  37.         waitUntil{scriptDone _thread || isNull (findDisplay 49)};
  38.         _abortButton ctrlEnable true;
  39.     };
  40. };
  41.  
  42. _canUseControls = {
  43.     if (playerSide isEqualTo west) exitWith {true};
  44.     if ((player getVariable ["restrained",FALSE]) || (player getVariable ["Escorting",FALSE]) || (player getVariable ["transporting",FALSE]) || (life_is_arrested) || (life_istazed) || (life_isknocked)) then {false} else {true};
  45. };
  46.  
  47. for "_i" from 0 to 1 step 0 do {
  48.     waitUntil{!isNull (findDisplay 49)};
  49.     _abortButton = CONTROL(49,104);
  50.     _abortButton buttonSetAction "[] call SOCK_fnc_updateRequest; [player] remoteExec [""TON_fnc_cleanupRequest"",2];";
  51.     _respawnButton = CONTROL(49,1010);
  52.     _fieldManual = CONTROL(49,122);
  53.  
  54.     //Block off our buttons first.
  55.     _abortButton ctrlEnable false;
  56.     _respawnButton ctrlEnable false;
  57.     _fieldManual ctrlEnable false; //Never re-enable, blocks an old script executor.
  58.  
  59.     _usebleCtrl = call _canUseControls;
  60.     _usebleCtrl spawn _escSync;
  61.     if (_usebleCtrl) then {
  62.         _respawnButton ctrlEnable true; //Enable the button.
  63.     };
  64.     waitUntil{isNull (findDisplay 49)};
  65. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top