1
0

fnc_jammersRemoveServer.sqf 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. params["_jammerObjectToRemove"];
  2. if(!isServer) exitWith { diag_log "[RD501 Jammers][Server Remove] Attempted to remove jammers from a non server context"; };
  3. private _jammers = localNamespace getVariable ["rd501_jammers_server",[]];;
  4. {
  5. _x params["_jammer", "_radius", "_strength", "_active"];
  6. if(_jammer isEqualTo _jammerObjectToRemove) exitWith
  7. {
  8. diag_log format["[RD501 Jammers][Server Remove] Removed Jammer '%1'", [_jammer, _radius, _strength, _active]];
  9. _jammers set [_foreachIndex, []];
  10. }
  11. } forEach (_jammers);
  12. private _previousLength = count _jammers;
  13. _jammers = _jammers - [[]];
  14. private _currentLength = count _jammers;
  15. if(_previousLength == _currentLength) exitWith {
  16. diag_log format["[RD501 Jammers][Server Remove] Specified jammer '%1' could not be found or was already removed", _jammerObjectToRemove];
  17. };
  18. localNamespace setVariable ["rd501_jammers_server",_jammers];
  19. private _pfhHandle = localNamespace getVariable ["rd501_jammers_serverPFH", -1];
  20. if(_pfhHandle isEqualTo -1) then {
  21. private _handle = [{
  22. _this call rd501_fnc_jammersServerPFH;
  23. }, 2, []] call CBA_fnc_addPerFrameHandler;
  24. localNamespace getVariable ["rd501_jammers_serverPFH", _handle];
  25. diag_log format["[RD501 Jammers][Server Remove] Started server PFH with handle '%1'", _handle];
  26. _handle
  27. };