Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **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. **
- Known bugs:
- 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.)
- -------------------
- init.sqf
- [] execVM "computerInteraction.sqf";
- -------------------
- computerInteraction.sqf
- if (!hasInterface) exitWith {};
- player setVariable ["poweredOnTVs", []];
- [] spawn {
- private _tvClasses = ["Land_FlatTV_01_F", "Land_TripodScreen_01_large_F"];
- private _antennaClass = "FPV_Retranslator";
- while {true} do {
- private _allTVs = [];
- { _allTVs append (allMissionObjects _x) } forEach _tvClasses;
- {
- private _tv = _x;
- if ((player distance _tv) > 10) then { // <-- Aquí está el rango de "desaparición" aumentado a 10m
- _tv setObjectTexture [0, "#(argb,8,8,3)color(0,0,0,1)"]; // Negro opaco solo local
- } else {
- if (_tv in (player getVariable ["poweredOnTVs", []])) then {
- if (_tv getVariable ["droneConnected", false]) then {
- private _rttName = _tv getVariable ["rttName", ""];
- if (_rttName != "") then {
- _tv setObjectTexture [0, format ["#(argb,512,512,1)r2t(%1,1)", _rttName]];
- };
- } else {
- if (_tv getVariable ["signalLost", false]) then {
- _tv setObjectTexture [0, "#(argb,8,8,3)color(1,0,0,1)"];
- } else {
- private _hasAntenna = false;
- {
- if (alive _x && (_x distance _tv) < 50) exitWith { _hasAntenna = true };
- } forEach allMissionObjects _antennaClass;
- if (_hasAntenna) then {
- _tv setObjectTexture [0, "#(argb,8,8,3)color(1,1,0,1)"];
- } else {
- _tv setObjectTexture [0, "#(argb,8,8,3)color(0,0,1,1)"];
- };
- };
- };
- } else {
- _tv setObjectTexture [0, "#(argb,8,8,3)color(0,0,0,1)"];
- };
- };
- // ** CAMBIO: menú general para todas las acciones a 2 metros de distancia **
- if ((player distance _tv) < 2 && {!(_tv getVariable ["menuAdded", false])}) then {
- _tv setVariable ["menuAdded", true];
- // Agregar la acción de prender/apagar TV
- _tv addAction ["🔌 Prender / Apagar TV", {
- params ["_target"];
- private _list = player getVariable ["poweredOnTVs", []];
- private _antena = false;
- {
- if (alive _x && (_x distance _target) < 50) exitWith { _antena = true };
- } forEach allMissionObjects "FPV_Retranslator";
- if (_target in _list) then {
- _list = _list - [_target];
- player setVariable ["poweredOnTVs", _list];
- private _cam = _target getVariable ["camObject", objNull];
- if (!isNull _cam) then { deleteVehicle _cam };
- _target setVariable ["droneConnected", false];
- _target setVariable ["disconnectActionAdded", false];
- _target setVariable ["camObject", objNull];
- _target setVariable ["droneMenuAdded", false];
- _target setVariable ["rttName", ""];
- _target setVariable ["signalLost", false];
- private _actions = actionIDs _target;
- { if (_x != -1) then { _target removeAction _x } } forEach _actions;
- _target setVariable ["menuAdded", false];
- _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(0,0,0,0)"];
- } else {
- _list pushBackUnique _target;
- player setVariable ["poweredOnTVs", _list];
- _target setVariable ["droneConnected", false];
- _target setVariable ["disconnectActionAdded", false];
- _target setVariable ["camObject", objNull];
- _target setVariable ["droneMenuAdded", false];
- _target setVariable ["rttName", ""];
- _target setVariable ["signalLost", false];
- if (_antena) then {
- _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,1,0,1)"];
- } else {
- _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(0,0,1,1)"];
- };
- };
- }];
- };
- } forEach _allTVs;
- private _list = player getVariable ["poweredOnTVs", []];
- private _allAntennas = allMissionObjects _antennaClass;
- {
- private _tv = _x;
- if (!alive _tv) then {
- _list = _list - [_tv];
- player setVariable ["poweredOnTVs", _list];
- continue;
- };
- private _hasAntenna = false;
- {
- if (alive _x && (_x distance _tv) < 50) exitWith { _hasAntenna = true };
- } forEach _allAntennas;
- if (_hasAntenna) then {
- if (!(_tv getVariable ["droneMenuAdded", false])) then {
- _tv setVariable ["droneMenuAdded", true];
- private _drones = vehicles select {
- alive _x && {typeOf _x in ["B_UAV_01_F", "orion_F_BLU"]}
- };
- {
- private _drone = _x;
- private _rttName = format ["uavRtt_%1", _forEachIndex];
- _tv setVariable ["rttName", _rttName];
- _tv addAction [format ["🎯 Mostrar cámara Drone %1 (%2m)", _forEachIndex + 1, round (_drone distance _tv)], {
- params ["_target", "_caller", "_actionId", "_args"];
- _args params ["_drone", "_rttName"];
- private _cam = "camera" camCreate getPosASL _drone;
- _cam cameraEffect ["Internal", "Back", _rttName];
- if (typeOf _drone == "orion_F_BLU") then {
- _cam attachTo [_drone, [0,0,0], "pip0_pos"];
- } else {
- _cam attachTo [_drone, [0,0,0], "PiP0_pos"];
- [_cam, _drone] spawn {
- params ["_cam", "_drone"];
- while {alive _cam && alive _drone} do {
- private _dir = (_drone selectionPosition "PiP0_pos") vectorFromTo (_drone selectionPosition "PiP0_dir");
- _cam setVectorDirAndUp [_dir, _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]];
- sleep 0.1;
- };
- };
- };
- _target setVariable ["droneConnected", true];
- _target setVariable ["camObject", _cam];
- _target setVariable ["rttName", _rttName];
- _target setVariable ["signalLost", false];
- _target setObjectTextureGlobal [0, format ["#(argb,512,512,1)r2t(%1,1)", _rttName]];
- systemChat format ["📺 Mostrando Drone en TV - %1", _rttName];
- // ** CAMBIO para evitar múltiples botones "Desconectar cámara" **
- if (!(_target getVariable ["disconnectActionAdded", false])) then {
- _target setVariable ["disconnectActionAdded", true];
- _target addAction ["🛑 Desconectar cámara", {
- params ["_target"];
- private _antena2 = false;
- {
- if (alive _x && (_x distance _target) < 50) exitWith { _antena2 = true };
- } forEach allMissionObjects "FPV_Retranslator";
- private _cam2 = _target getVariable ["camObject", objNull];
- if (!isNull _cam2) then { deleteVehicle _cam2 };
- _target setVariable ["droneConnected", false];
- _target setVariable ["disconnectActionAdded", false];
- _target setVariable ["camObject", objNull];
- _target setVariable ["rttName", ""];
- _target setVariable ["signalLost", false];
- if (_antena2) then {
- _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,1,0,1)"];
- } else {
- _target setObjectTextureGlobal [0, "#(argb,8,8,3)color(0,0,1,1)"];
- };
- }];
- };
- [_target, _drone] spawn {
- params ["_tvMonitor", "_uav"];
- waitUntil { sleep 1; !alive _uav };
- _tvMonitor setVariable ["droneConnected", false];
- _tvMonitor setVariable ["disconnectActionAdded", false];
- _tvMonitor setVariable ["camObject", objNull];
- _tvMonitor setVariable ["rttName", ""];
- _tvMonitor setVariable ["signalLost", true];
- _tvMonitor setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,0,0,1)"];
- };
- }, [_drone, _rttName]];
- } forEach _drones;
- };
- } else {
- if (_tv getVariable ["droneConnected", false]) then {
- private _cam = _tv getVariable ["camObject", objNull];
- if (!isNull _cam) then { deleteVehicle _cam };
- _tv setVariable ["droneConnected", false];
- _tv setVariable ["disconnectActionAdded", false];
- _tv setVariable ["camObject", objNull];
- _tv setVariable ["rttName", ""];
- _tv setVariable ["signalLost", true];
- _tv setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,0,0,1)"];
- } else {
- _tv setObjectTextureGlobal [0, "#(argb,8,8,3)color(0,0,1,1)"];
- };
- if (_tv getVariable ["droneMenuAdded", false]) then {
- _tv setVariable ["droneMenuAdded", false];
- private _actions = actionIDs _tv;
- { if (_x != -1) then { _tv removeAction _x } } forEach _actions;
- _tv setVariable ["menuAdded", false];
- };
- };
- } forEach _list;
- sleep 0.5;
- };
- };
- ------------------------------
Advertisement
Add Comment
Please, Sign In to add comment