Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **WORKS ONLY WITH TV "Land_FlatTV_01_F" . To work properly you need to place a Antena "FPV_Retranslator" no less 50 meters from the TV. Otherwise won't work. **
- init.sqf
- [] execVM "computerInteraction.sqf";
- -------------------
- computerInteraction.sqf
- if (!hasInterface) exitWith {};
- systemChat "📱 tvInteraction.sqf corriendo...";
- player setVariable ["poweredOnTVs", []];
- [] spawn {
- private _tvClass = "Land_FlatTV_01_F";
- private _antennaClass = "FPV_Retranslator";
- while {true} do {
- private _allTVs = allMissionObjects _tvClass;
- {
- private _tv = _x;
- if ((player distance _tv) < 3 && {!(_tv getVariable ["menuAdded", false])}) then {
- _tv setVariable ["menuAdded", true];
- _tv addAction ["🔌 Prender / Apagar TV", {
- params ["_target"];
- private _list = player getVariable ["poweredOnTVs", []];
- // Chequear antena cerca
- private _antena = false;
- {
- if (alive _x && (_x distance _target) < 50) exitWith { _antena = true };
- } forEach allMissionObjects "FPV_Retranslator";
- if (_target in _list) then {
- // APAGAR TV = también desconecta y limpia todo
- _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];
- 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)"];
- systemChat "💤 TV apagada.";
- } else {
- // ENCENDER TV
- _list pushBackUnique _target;
- player setVariable ["poweredOnTVs", _list];
- _target setVariable ["droneConnected", false];
- _target setVariable ["disconnectActionAdded", false];
- _target setVariable ["camObject", objNull];
- _target setVariable ["droneMenuAdded", 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)"];
- };
- systemChat "🔦 TV encendida.";
- };
- }];
- };
- } 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];
- } else {
- 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 == "B_UAV_01_F"} };
- {
- private _drone = _x;
- private _rttName = format ["uavRtt_%1", _forEachIndex];
- _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];
- _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 setObjectTextureGlobal [0, format ["#(argb,512,512,1)r2t(%1,1)", _rttName]];
- systemChat format ["📺 Mostrando Drone en TV - %1", _rttName];
- if (!(_target getVariable ["disconnectActionAdded", false])) then {
- private _disconnectActionId = _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];
- 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)"];
- };
- systemChat "📺 Cámara desconectada.";
- _this select 2 call {
- private _actionId = _this;
- _target removeAction _actionId;
- };
- }];
- _target setVariable ["disconnectActionAdded", true];
- };
- [_target, _drone] spawn {
- params ["_tvMonitor", "_uav"];
- waitUntil { sleep 1; !alive _uav };
- _tvMonitor setVariable ["droneConnected", false];
- _tvMonitor setVariable ["disconnectActionAdded", false];
- _tvMonitor setVariable ["camObject", objNull];
- _tvMonitor setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,0,0,1)"];
- systemChat "📱 Drone destruido. TV en rojo.";
- };
- }, [_drone, _rttName]];
- } forEach _drones;
- };
- } else {
- // SIN ANTENA: desconectar y limpiar
- 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 setObjectTextureGlobal [0, "#(argb,8,8,3)color(1,0,0,1)"];
- systemChat "📡 Feed perdido: sin antena.";
- } 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
Advertisement