added handling on SQF for letting the OTS server handle sync links on entities with core armatak module

This commit is contained in:
Valmo Trindade
2024-12-11 04:11:46 -03:00
parent d10dd71dca
commit 7e143c1b6b
5 changed files with 43 additions and 10 deletions

View File

@@ -4,5 +4,9 @@ if (roleDescription _unit != "") then {
_callsign = name _unit + " | " + roleDescription _unit;
} else {
_callsign = name _unit;
if (_callsign == "Error: No unit") then {
_callsign = getText(configFile >> "CfgVehicles" >> typeOf _unit >> "displayName");
};
};
_callsign

View File

@@ -1,4 +1,5 @@
params["_drone"];
private _location = (getPos _drone) call armatak_fnc_convert_location;
private _atak_uid = _drone call armatak_fnc_extract_uuid;
private _atak_latitude = _location select 0;
@@ -6,10 +7,17 @@ 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 = _drone getVariable "_atak_uav_callsign";
private _atak_callsign = "UAV";
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;
if (isUAVConnected _unit) then {
_atak_callsign = format ["[UAV]%1", typeOf _unit ];
} else {
_atak_callsign = getText(configFile >> "CfgVehicles" >> typeOf _unit >> "displayName");
};
switch (side _drone) do {
case "WEST": {
_atak_role = "a-f-A-M-F-Q"
@@ -27,6 +35,7 @@ switch (side _drone) do {
_atak_role = "a-f-A-M-F-Q"
};
};
_drone_info = [_atak_uid, _atak_latitude, _atak_longitude, _atak_speed, _atak_bearing, _atak_role, _atak_callsign, _atak_altitude, _atak_server_instance, _atak_server_instance_token];
_drone_info

View File

@@ -3,6 +3,7 @@
// function description: Receives a player's unit as param and return the information array needed to send the HTTP request
params["_unit"];
private _location = (getPos _unit) call armatak_fnc_convert_location;
private _atak_uid = [_unit] call armatak_fnc_extract_uuid;
@@ -15,11 +16,6 @@ private _atak_callsign = [_unit] call armatak_fnc_extract_callsign;
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];

View File

@@ -19,9 +19,9 @@ if (isServer && _activated) exitWith {
missionNamespace setVariable ["_atak_server_instance", _atak_fulladdress];
missionNamespace setVariable ["_atak_server_instance_username", _atak_api_username];
missionNamespace setVariable ["_atak_server_instance_password", _atak_api_password];
/*
_atak_server_instance_token = call armatak_fnc_extract_auth_token;
if (_atak_server_instance_token == "") then {
private _warning = format ["<t color='#FF0000'>ARMATAK</t><br/> %1", "Connection Failed"];
[[_warning, 2]] call CBA_fnc_notify;
@@ -29,7 +29,31 @@ if (isServer && _activated) exitWith {
private _warning = format ["<t color='#2B7319'>ARMATAK</t><br/> %1", "Connected"];
[[_warning, 2]] call CBA_fnc_notify;
};
*/
_syncUnits = synchronizedObjects _logic;
missionNamespace setVariable ["_armatak_marked_units", _syncUnits];
[{
[{
_syncedUnits = missionNamespace getVariable "_armatak_marked_units";
_markers = [];
{
if (unitIsUAV _x) then {
_marker = _x call armatak_fnc_extract_drone_info;
_markers append [_marker];
} else {
_marker = _x call armatak_fnc_extract_info;
_markers append [_marker];
};
} forEach _syncedUnits;
_request = "armatak" callExtension ["ots_api:post", [_markers]];
systemChat format ["Result: %1, Code: %2", _request select 0, _request select 1];
}, 1, []] call CBA_fnc_addPerFrameHandler;
}, [], 5] call CBA_fnc_waitAndExecute;
};
true;