papijuan23

UAV FEED PiP

Jun 18th, 2025 (edited)
4,733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 11.77 KB | Gaming | 0 0
  1. **WORKS ONLY WITH TV "Land_FlatTV_01_F" and "Land_TripodScreen_01_large_F" .  To work properly you need to place a Antena "FPV_Retranslator" no less 50 meters from the TV. Otherwise won't work. **
  2.  
  3. Known bugs:
  4.  
  5. In the Orion camera (If you are aiming the turret at a fixed spot, the monitors will only show the driver'span class="re5"> s POV.)
  6.  
  7.  
  8. -------------------
  9.  
  10. init.sqf
  11.  
  12. [] execVM "computerInteraction.sqf";
  13.  
  14.  
  15.  
  16. -------------------
  17.  
  18.  
  19. computerInteraction.sqf
  20.  
  21.  
  22. if (!hasInterface) exitWith {};
  23.  
  24. player setVariable ["poweredOnTVs", []];
  25.  
  26. [] spawn {
  27.     private _tvClasses = ["Land_FlatTV_01_F", "Land_TripodScreen_01_large_F"];
  28.     private _antennaClass = "FPV_Retranslator";
  29.  
  30.     while {true} do {
  31.         private _allTVs = [];
  32.         { _allTVs append (allMissionObjects _x) } forEach _tvClasses;
  33.  
  34.         {
  35.             private _tv = _x;
  36.  
  37.             if ((player distance _tv) > 10) then {  // <-- Aquí está el rango de "desaparición" aumentado a 10m
  38.                 _tv setObjectTexture [0, "#(argb,8,8,3)color(0,0,0,1)"];  // Negro opaco solo local
  39.             } else {
  40.                 if (_tv in (player getVariable ["poweredOnTVs", []])) then {
  41.                     if (_tv getVariable ["droneConnected", false]) then {
  42.                         private _rttName = _tv getVariable ["rttName", ""];
  43.                         if (_rttName != "") then {
  44.                             _tv setObjectTexture [0, format ["#(argb,512,512,1)r2t(%1,1)", _rttName]];
  45.                         };
  46.                     } else {
  47.                         if (_tv getVariable ["signalLost", false]) then {
  48.                             _tv setObjectTexture [0, "#(argb,8,8,3)color(1,0,0,1)"];
  49.                         } else {
  50.                             private _hasAntenna = false;
  51.                             {
  52.                                 if (alive _x && (_x distance _tv) < 50) exitWith { _hasAntenna = true };
  53.                             } forEach allMissionObjects _antennaClass;
  54.  
  55.                             if (_hasAntenna) then {
  56.                                 _tv setObjectTexture [0, "#(argb,8,8,3)color(1,1,0,1)"];
  57.                             } else {
  58.                                 _tv setObjectTexture [0, "#(argb,8,8,3)color(0,0,1,1)"];
  59.                             };
  60.                         };
  61.                     };
  62.                 } else {
  63.                     _tv setObjectTexture [0, "#(argb,8,8,3)color(0,0,0,1)"];
  64.                 };
  65.             };
  66.  
  67.             // ** CAMBIO: menú general para todas las acciones a 2 metros de distancia **
  68.             if ((player distance _tv) < 2 && {!(_tv getVariable ["menuAdded", false])}) then {
  69.                 _tv setVariable ["menuAdded", true];
  70.  
  71.                 // Agregar la acción de prender/apagar TV
  72.                 _tv addAction ["🔌 Prender / Apagar TV", {
  73.                     params ["_target"];
  74.                     private _list = player getVariable ["poweredOnTVs", []];
  75.  
  76.                     private _antena = false;
  77.                     {
  78.                         if (alive _x && (_x distance _target) < 50) exitWith { _antena = true };
  79.                     } forEach allMissionObjects "FPV_Retranslator";
  80.  
  81.                     if (_target in _list) then {
  82.                         _list = _list - [_target];
  83.                         player setVariable ["poweredOnTVs", _list];
  84.  
  85.                         private _cam = _target getVariable ["camObject", objNull];
  86.                         if (!isNull _cam) then { deleteVehicle _cam };
  87.  
  88.                         _target setVariable ["droneConnected", false];
  89.                         _target setVariable ["disconnectActionAdded", false];
  90.                         _target setVariable ["camObject", objNull];
  91.                         _target setVariable ["droneMenuAdded", false];
  92.                         _target setVariable ["rttName", ""];
  93.                         _target setVariable ["signalLost", false];
  94.  
  95.                         private _actions = actionIDs _target;
  96.                         { if (_x != -1) then { _target removeAction _x } } forEach _actions;
  97.  
  98.                         _target setVariable ["menuAdded", false];
  99.                         _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(0,0,0,0)"];
  100.                     } else {
  101.                         _list pushBackUnique _target;
  102.                         player setVariable ["poweredOnTVs", _list];
  103.  
  104.                         _target setVariable ["droneConnected", false];
  105.                         _target setVariable ["disconnectActionAdded", false];
  106.                         _target setVariable ["camObject", objNull];
  107.                         _target setVariable ["droneMenuAdded", false];
  108.                         _target setVariable ["rttName", ""];
  109.                         _target setVariable ["signalLost", false];
  110.  
  111.                         if (_antena) then {
  112.                             _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,1,0,1)"];
  113.                         } else {
  114.                             _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(0,0,1,1)"];
  115.                         };
  116.                     };
  117.                 }];
  118.             };
  119.         } forEach _allTVs;
  120.  
  121.         private _list = player getVariable ["poweredOnTVs", []];
  122.         private _allAntennas = allMissionObjects _antennaClass;
  123.  
  124.         {
  125.             private _tv = _x;
  126.             if (!alive _tv) then {
  127.                 _list = _list - [_tv];
  128.                 player setVariable ["poweredOnTVs", _list];
  129.                 continue;
  130.             };
  131.  
  132.             private _hasAntenna = false;
  133.             {
  134.                 if (alive _x && (_x distance _tv) < 50) exitWith { _hasAntenna = true };
  135.             } forEach _allAntennas;
  136.  
  137.             if (_hasAntenna) then {
  138.                 if (!(_tv getVariable ["droneMenuAdded", false])) then {
  139.                     _tv setVariable ["droneMenuAdded", true];
  140.  
  141.                     private _drones = vehicles select {
  142.                         alive _x && {typeOf _x in ["B_UAV_01_F", "orion_F_BLU"]}
  143.                     };
  144.  
  145.                     {
  146.                         private _drone = _x;
  147.                         private _rttName = format ["uavRtt_%1", _forEachIndex];
  148.                         _tv setVariable ["rttName", _rttName];
  149.  
  150.                         _tv addAction [format ["🎯 Mostrar cámara Drone %1 (%2m)", _forEachIndex + 1, round (_drone distance _tv)], {
  151.                             params ["_target", "_caller", "_actionId", "_args"];
  152.                             _args params ["_drone", "_rttName"];
  153.  
  154.                             private _cam = "camera" camCreate getPosASL _drone;
  155.                             _cam cameraEffect ["Internal", "Back", _rttName];
  156.  
  157.                             if (typeOf _drone == "orion_F_BLU") then {
  158.                                 _cam attachTo [_drone, [0,0,0], "pip0_pos"];
  159.                             } else {
  160.                                 _cam attachTo [_drone, [0,0,0], "PiP0_pos"];
  161.                                 [_cam, _drone] spawn {
  162.                                     params ["_cam", "_drone"];
  163.                                     while {alive _cam && alive _drone} do {
  164.                                         private _dir = (_drone selectionPosition "PiP0_pos") vectorFromTo (_drone selectionPosition "PiP0_dir");
  165.                                         _cam setVectorDirAndUp [_dir, _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]];
  166.                                         sleep 0.1;
  167.                                     };
  168.                                 };
  169.                             };
  170.  
  171.                             _target setVariable ["droneConnected", true];
  172.                             _target setVariable ["camObject", _cam];
  173.                             _target setVariable ["rttName", _rttName];
  174.                             _target setVariable ["signalLost", false];
  175.                             _target setObjectTextureGlobal [0, format ["#(argb,512,512,1)r2t(%1,1)", _rttName]];
  176.                             systemChat format ["📺 Mostrando Drone en TV - %1", _rttName];
  177.  
  178.                             // ** CAMBIO para evitar múltiples botones "Desconectar cámara" **
  179.                             if (!(_target getVariable ["disconnectActionAdded", false])) then {
  180.                                 _target setVariable ["disconnectActionAdded", true];
  181.                                 _target addAction ["🛑 Desconectar cámara", {
  182.                                     params ["_target"];
  183.  
  184.                                     private _antena2 = false;
  185.                                     {
  186.                                         if (alive _x && (_x distance _target) < 50) exitWith { _antena2 = true };
  187.                                     } forEach allMissionObjects "FPV_Retranslator";
  188.  
  189.                                     private _cam2 = _target getVariable ["camObject", objNull];
  190.                                     if (!isNull _cam2) then { deleteVehicle _cam2 };
  191.  
  192.                                     _target setVariable ["droneConnected", false];
  193.                                     _target setVariable ["disconnectActionAdded", false];
  194.                                     _target setVariable ["camObject", objNull];
  195.                                     _target setVariable ["rttName", ""];
  196.                                     _target setVariable ["signalLost", false];
  197.  
  198.                                     if (_antena2) then {
  199.                                         _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,1,0,1)"];
  200.                                     } else {
  201.                                         _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(0,0,1,1)"];
  202.                                     };
  203.                                 }];
  204.                             };
  205.  
  206.                             [_target, _drone] spawn {
  207.                                 params ["_tvMonitor", "_uav"];
  208.                                 waitUntil { sleep 1; !alive _uav };
  209.                                 _tvMonitor setVariable ["droneConnected", false];
  210.                                 _tvMonitor setVariable ["disconnectActionAdded", false];
  211.                                 _tvMonitor setVariable ["camObject", objNull];
  212.                                 _tvMonitor setVariable ["rttName", ""];
  213.                                 _tvMonitor setVariable ["signalLost", true];
  214.                                 _tvMonitor setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,0,0,1)"];
  215.                             };
  216.                         }, [_drone, _rttName]];
  217.                     } forEach _drones;
  218.                 };
  219.             } else {
  220.                 if (_tv getVariable ["droneConnected", false]) then {
  221.                     private _cam = _tv getVariable ["camObject", objNull];
  222.                     if (!isNull _cam) then { deleteVehicle _cam };
  223.  
  224.                     _tv setVariable ["droneConnected", false];
  225.                     _tv setVariable ["disconnectActionAdded", false];
  226.                     _tv setVariable ["camObject", objNull];
  227.                     _tv setVariable ["rttName", ""];
  228.                     _tv setVariable ["signalLost", true];
  229.                     _tv setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,0,0,1)"];
  230.                 } else {
  231.                     _tv setObjectTextureGlobal [0, "#(argb,8,8,3)color(0,0,1,1)"];
  232.                 };
  233.  
  234.                 if (_tv getVariable ["droneMenuAdded", false]) then {
  235.                     _tv setVariable ["droneMenuAdded", false];
  236.  
  237.                     private _actions = actionIDs _tv;
  238.                     { if (_x != -1) then { _tv removeAction _x } } forEach _actions;
  239.  
  240.                     _tv setVariable ["menuAdded", false];
  241.                 };
  242.             };
  243.         } forEach _list;
  244.  
  245.         sleep 0.5;
  246.     };
  247. };
  248.  
  249.  
  250.  
  251. ------------------------------
  252.  
Advertisement
Add Comment
Please, Sign In to add comment