Guest User

Untitled

a guest
Jul 8th, 2018
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.73 KB | None | 0 0
  1. _logic = _this param [0,objnull,[objnull]];
  2. _activated = _this param [2,true,[true]];
  3.  
  4. if (_activated) then {
  5.  
  6.     //--- Add
  7.     _name = _logic getvariable ["Name",""];
  8.     _name = _name call bis_fnc_localize;
  9.     _typeID = (_logic getvariable ["Type","0"]) call bis_fnc_parsenumber;
  10.     _sideID = (_logic getvariable ["Side","-1"]) call bis_fnc_parsenumber;
  11.  
  12.     //--- Detect the leading side
  13.     if (_sideID < 0) then {
  14.         if (ismultiplayer) then {
  15.             _maxScore = -1;
  16.             {
  17.                 _score = scoreside _x;
  18.                 if (_score > _maxScore) then {
  19.                     _maxScore = _score;
  20.                     _sideID = _x call bis_fnc_sideID;
  21.                 } else {
  22.                     if (_score == _maxScore) then {
  23.                         _sideID = -1;
  24.                     };
  25.                 };
  26.             } foreach [opfor,blufor,independent,civilian];
  27.         } else {
  28.             _sideID = (player call bis_fnc_objectSide) call bis_fnc_sideID;
  29.         };
  30.     };
  31.  
  32.     if (_sideID >= 0) then {
  33.         _side = _sideID call bis_fnc_sideType;
  34.         _pos = position _logic;
  35.         _markerPrefix = "respawn_";
  36.         _markerType = ["respawn_inf","respawn_unknown","respawn_motor","respawn_armor","respawn_air","respawn_plane","respawn_naval"] select _typeID;
  37.         _respawnPositions = [];
  38.  
  39.         if (_typeID > 0) then {
  40.             _markerPrefix = "respawn_vehicle_";
  41.         } else {
  42.             {
  43.                 if (_x iskindof "AllVehicles") then {
  44.                     _respawn = [_side,_x] call bis_fnc_addRespawnPosition;
  45.                     _respawnPositions set [count _respawnPositions,_respawn];
  46.                 };
  47.             } foreach (synchronizedobjects _logic);
  48.         };
  49.  
  50.         if (count _respawnPositions == 0) then {
  51.  
  52.             //--- Respawn on position (marker)
  53.             _markerSide = ["east","west","guerrila","civilian"] select _sideID;
  54.             _markerPrefix = _markerPrefix + _markerSide;
  55.  
  56.             _respawn = createmarker [_markerPrefix + str _logic,_pos];
  57.             _respawn setmarkerdir ((round direction _logic) * 360);
  58.             _respawn setmarkersize [1,1];
  59.             _respawn setmarkercolor ([_side,true] call bis_fnc_sidecolor);
  60.             _respawn setmarkertype _markerType;
  61.             _respawn setmarkertext _name;
  62.             _respawnPositions set [count _respawnPositions,_respawn];
  63.         };
  64.         _logic setvariable ["respawn",_respawnPositions];
  65.  
  66.         _type = gettext (configfile >> "cfgmarkers" >> _markerType >> "name");
  67.         if (_name == "") then {_name = format [localize "str_a3_bis_fnc_respawnmenuposition_grid",mapgridposition _pos];};
  68.         [["RespawnAdded",[_type,_name,_markerType call bis_fnc_textureMarker]],"BIS_fnc_showNotification",_side] call bis_fnc_mp;
  69.     } else {
  70.         ["Respawn %1 not added, all sides have the same score.",_logic] call bis_fnc_logFormat;
  71.     };
  72. } else {
  73.  
  74.     //--- Remove
  75.     _respawn = _logic getvariable ["respawn",[]];
  76.     _respawn = _respawn param [0,[],[[],""]];
  77.     if (typename _respawn == typename []) then {
  78.         if (count _respawn == 2) then {
  79.             _respawn call bis_fnc_removeRespawnPosition;
  80.         };
  81.     } else {
  82.         deletemarker _respawn;
  83.     };
  84. };
Add Comment
Please, Sign In to add comment