added a more refined way to handle drones used by the player

This commit is contained in:
Valmo Trindade
2024-09-03 00:21:17 -03:00
parent eacccd8911
commit bc07343edb
3 changed files with 33 additions and 11 deletions

View File

@@ -1,8 +1,4 @@
params["_unit"];
_drone = vehicle (getConnectedUAVUnit _unit);
if (isNull _drone) exitWith {};
params["_drone"];
private _location = (getPos _drone) call armatak_fnc_convert_location;
@@ -12,7 +8,7 @@ private _atak_longitude = _location select 1;
private _atak_speed = speed _drone;
private _atak_bearing = parseNumber ((getDir _drone) toFixed 0);
private _atak_role = "a-f-A";
private _atak_callsign = "[UAV]" + name _unit;
private _atak_callsign = _drone getVariable "_atak_uav_callsign";
private _atak_server_instance = missionNamespace getVariable "_atak_server_instance";
private _atak_server_instance_token = missionNamespace getVariable "_atak_server_instance_token";
private _atak_altitude = _location select 2;

View File

@@ -16,6 +16,13 @@ private _atak_altitude = _location select 2;
private _atak_server_instance = missionNamespace getVariable "_atak_server_instance";
private _atak_server_instance_token = missionNamespace getVariable "_atak_server_instance_token";
_drone = vehicle (getConnectedUAVUnit _unit);
if (!isNull _drone) then {
_drone setVariable ["_atak_uav_connected", true];
_drone setVariable ["_atak_uav_callsign", "[UAV]" + name _unit];
};
_unit_info = [_atak_uid, _atak_latitude, _atak_longitude, _atak_speed, _atak_bearing, _atak_role, _atak_callsign, _atak_altitude, _atak_server_instance, _atak_server_instance_token];
_unit_info

View File

@@ -22,11 +22,11 @@ if (isServer && _activated) exitWith {
_atak_server_instance_token = call armatak_fnc_extract_auth_token;
if (isNull _atak_server_instance_token) then {
private _warning = format ["<t color='#2B7319'>ARMATAK</t><br/> %1", "Connected"];
if (_atak_server_instance_token == "") then {
private _warning = format ["<t color='#FF0000'>ARMATAK</t><br/> %1", "Connection Failed"];
[[_warning, 2]] call CBA_fnc_notify;
} else {
private _warning = format ["<t color='#FF0000'>ARMATAK</t><br/> %1", "Connection Failed"];
private _warning = format ["<t color='#2B7319'>ARMATAK</t><br/> %1", "Connected"];
[[_warning, 2]] call CBA_fnc_notify;
};
@@ -36,8 +36,14 @@ if (isServer && _activated) exitWith {
{
private _unit = _x;
_unit call armatak_fnc_postMarker;
_unit call armatak_fnc_postDroneMarker;
_unit call armatak_fnc_extract_drone_info;
} forEach playableUnits;
{
private _drone = _x;
if (_drone getVariable "_atak_uav_connected") then {
_drone call armatak_fnc_postDroneMarker;
};
} forEach allUnitsUAV;
}, 1, []] call CBA_fnc_addPerFrameHandler;
}, [], 1] call CBA_fnc_waitAndExecute;
@@ -46,15 +52,28 @@ if (isServer && _activated) exitWith {
private _unit = _x;
_unit call armatak_fnc_deleteMarker;
} forEach playableUnits;
{
private _drone = _x;
_drone call armatak_fnc_deleteMarker;
} forEach allUnitsUAV;
}];
} else {
[{
player call armatak_fnc_postMarker;
player call armatak_fnc_postDroneMarker;
{
private _drone = _x;
if (_drone getVariable "_atak_uav_connected") then {
_drone call armatak_fnc_postDroneMarker;
};
} forEach allUnitsUAV;
}, 1, []] call CBA_fnc_addPerFrameHandler;
addMissionEventHandler ["Ended", {
player call armatak_fnc_deleteMarker;
{
private _drone = _x;
_drone call armatak_fnc_deleteMarker;
} forEach allUnitsUAV;
}];
};
};