diff --git a/addons/main/functions/extract_data/fn_extract_callsign.sqf b/addons/main/functions/extract_data/fn_extract_callsign.sqf index 9d91d51..2ed1fe0 100644 --- a/addons/main/functions/extract_data/fn_extract_callsign.sqf +++ b/addons/main/functions/extract_data/fn_extract_callsign.sqf @@ -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 \ No newline at end of file diff --git a/addons/main/functions/extract_data/fn_extract_drone_info.sqf b/addons/main/functions/extract_data/fn_extract_drone_info.sqf index cbeb07c..67a9bac 100644 --- a/addons/main/functions/extract_data/fn_extract_drone_info.sqf +++ b/addons/main/functions/extract_data/fn_extract_drone_info.sqf @@ -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 \ No newline at end of file diff --git a/addons/main/functions/extract_data/fn_extract_info.sqf b/addons/main/functions/extract_data/fn_extract_info.sqf index 9b2d8cd..51fe916 100644 --- a/addons/main/functions/extract_data/fn_extract_info.sqf +++ b/addons/main/functions/extract_data/fn_extract_info.sqf @@ -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]; diff --git a/addons/main/functions/fn_init.sqf b/addons/main/functions/fn_init.sqf index e6a21f4..9f4662d 100644 --- a/addons/main/functions/fn_init.sqf +++ b/addons/main/functions/fn_init.sqf @@ -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 ["ARMATAK
%1", "Connection Failed"]; [[_warning, 2]] call CBA_fnc_notify; @@ -29,7 +29,31 @@ if (isServer && _activated) exitWith { private _warning = format ["ARMATAK
%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; \ No newline at end of file diff --git a/src/util.rs b/src/util.rs index 8a05f68..1eca44d 100644 --- a/src/util.rs +++ b/src/util.rs @@ -62,7 +62,7 @@ pub async fn async_post_markers(data: Vec) { let parsed_address: String = data[0].api_address.clone() + "/api/markers?auth_token=" + &authentication_token; - let mut status: String = "fetching".to_string(); + let mut status: String = format!("fetching {} markers", data.len().to_string()); info!("{}", status);