Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.79 KB | None | 0 0
  1. waitUntil {time > 0};
  2. sharp_func_zone={
  3.     params ["_zone","_timeToCap","_flag","_debug","_action","_actionScript"];
  4.     _flag setVariable ["sharp_isCaptured",false,true];
  5.     if !(canSuspend) exitWith {systemChat "Non-Scheduled environment, use []spawn sharp_func_zone";};
  6.     if (_debug) then {
  7.         systemChat format ["Zone initialised on zone %1, timetocap %2, flag %3",_zone,_timeToCap,_flag];
  8.     };
  9.     private _capTime=0;
  10.     private _capped=false;
  11.     while {true}do{
  12.         _count0={(side _x==resistance && _x inArea _zone && alive _x)} count allUnits;
  13.         _count1={(side _x==west && _x inArea _zone && alive _x)} count allUnits;
  14.         if (_count0 > _count1) then {
  15.             _capTime=_capTime+1;
  16.             if (_debug) then {
  17.                 systemChat format ["%1 capturing: %2",_zone,_capTime];
  18.             };
  19.         }else{
  20.             if (_count0==0 && _count1==0) then {
  21.                 if (_debug) then {
  22.                     systemChat format ["no one is inside the zone yet %1",_zone];
  23.                 };
  24.             }else{
  25.                 _capTime=0;
  26.                 if (_debug) then {
  27.                     systemChat format ["%1 failed to capture",_zone];
  28.                 };
  29.                 _flag setVariable ["sharp_isCaptured",false,true];
  30.             };
  31.         };
  32.         if (_capTime ==10) exitWith{
  33.             if (_debug) then {
  34.                 systemChat format ["%1 Captured",_zone];
  35.             };
  36.             _flag setVariable ["sharp_isCaptured",true,true];
  37.             //[[],{_flag addAction [_action,_actionScript];}] remoteExec ["call",resistance];
  38.             [[_flag],
  39.             {
  40.                 waitUntil {!isNull (findDisplay 46)};
  41.                 if !(isNil KEYDOWN_HANDLER) exitWith {};
  42.                 KEYDOWN_HANDLER=(findDisplay 46) displayAddEventHandler ["keyDown",
  43.                 {
  44.                     switch (_this select 1) do
  45.                     {
  46.                         case 35:{
  47.                             _list=nearestObjects [getPos player,[],5];
  48.                             if (count _list ==0) exitWIth {hint "No flag in range"};
  49.                             {
  50.                                 if ((_x getVariable ["sharp_isCaptured","nil"]) != "nil") then {
  51.                                     _isCaptured=_x getVariable ["sharp_isCaptured",false];
  52.                                     if !(_isCaptured) exitWith {hint "that flag is not captured"};
  53.                                     []execVM _actionScript;
  54.                                 };
  55.                             }forEach _list;
  56.                         };
  57.                     };
  58.                 }];
  59.             }]remoteExec ["spawn",resistance];
  60.             _capped=true;
  61.         };
  62.         sleep 1;
  63.     };
  64.     waitUntil{({(side _x==resistance && _x inArea _zone && alive _x)} count allUnits < {(side _x==west && _x inArea _zone && alive _x)} count allUnits) && _capped};
  65.     if (_debug) then {
  66.         systemChat format ["%1 was recaptured by enemy team",_zone];
  67.     };
  68.     removeAllActions _flag;
  69.     [_zone,_timeToCap,_flag,_debug,_action,_actionScript]spawn sharp_func_zone;
  70. };
  71. sleep 1;
  72. ["ao1",10,flag1,true,"HALO","thisScriptWillNotBeFound.sqf"]spawn sharp_func_zone;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement