Advertisement
Feuerex

vehicle counter for destruction

Nov 15th, 2023
1,458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.15 KB | Gaming | 0 0
  1. this setVariable ["fex_vehicleCounter",false,true];
  2.  
  3. this addEventHandler ["GetIn", {
  4.     params ["_vehicle", "_role", "_unit", "_turret"];
  5.     if (count crew _vehicle > 0) then {
  6.         hint format ["Someone entered vehicle %1. Resetting counter", typeOf _vehicle];
  7.         _vehicle setVariable ["fex_vehicleCounter",false,true];
  8.     }
  9. }];
  10. this addEventHandler ["GetOut", {
  11.     params ["_vehicle", "_role", "_unit", "_turret"];
  12.     if (count crew _vehicle == 0) then
  13.     {
  14.         hint format ["Vehicle %1 is empty, starting counter", typeOf _vehicle];
  15.         _vehicle setVariable ["fex_vehicleCounter",true,true];
  16.         _0 = _vehicle spawn
  17.         {
  18.             _internalCounter = 30;
  19.             while {_this getVariable "fex_vehicleCounter" && _internalCounter > 0} do
  20.             {
  21.                 uiSleep 1;
  22.                 _internalCounter = _internalCounter - 1;
  23.                 systemChat format ["%1", _internalCounter];
  24.             };
  25.             if (_internalCounter == 0 && count crew _this == 0) then
  26.             {
  27.                 hint format ["Vehicle %1 is empty for too long. Destroying vehicle", typeOf _this];
  28.                 _this setDamage 1;
  29.             } else
  30.             {
  31.                 uiSleep 1;
  32.                 hint format ["Counter for vehicle %1 has been stopped by other means", typeOf _this];
  33.             };
  34.         };
  35.     };
  36. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement