mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 16:03:31 +00:00
Added whole websocket handling to the client addon
This commit is contained in:
61
addons/client/functions/fnc_convertClientLocation.sqf
Normal file
61
addons/client/functions/fnc_convertClientLocation.sqf
Normal file
@@ -0,0 +1,61 @@
|
||||
params["_latitude", "_longitude", "_altitude"];
|
||||
|
||||
_position = [_latitude, _longitude, _altitude];
|
||||
|
||||
_realLocation = null;
|
||||
|
||||
switch (toLower worldName) do {
|
||||
case "altis": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_altis;
|
||||
};
|
||||
case "stratis": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_stratis;
|
||||
};
|
||||
case "malden": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_malden;
|
||||
};
|
||||
case "vr": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_vr;
|
||||
};
|
||||
case "cucui": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_cucui;
|
||||
};
|
||||
case "chernarus": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_chernarus;
|
||||
};
|
||||
case "chernarus_summer": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_chernarus;
|
||||
};
|
||||
case "chernarus_winter": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_chernarus;
|
||||
};
|
||||
case "bootcamp_acr": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_bukovina;
|
||||
};
|
||||
case "woodland_acr": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_bystrika;
|
||||
};
|
||||
case "mountains_acr": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_takistan_montains;
|
||||
};
|
||||
case "sara_dbe1": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_united_sahrani;
|
||||
};
|
||||
case "saralite": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_southen_sahrani;
|
||||
};
|
||||
case "enoch": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_livonia;
|
||||
};
|
||||
case "kunduz": {
|
||||
_realLocation = _position call armatak_fnc_convert_to_kunduz;
|
||||
};
|
||||
default {
|
||||
_warning = format ["<t color='#FF8021'>ARMATAK</t><br/> %1", "Unsupported Map"];
|
||||
[[_warning, 1.5]] call CBA_fnc_notify;
|
||||
|
||||
_realLocation = [0, 0, 0];
|
||||
};
|
||||
};
|
||||
|
||||
_realLocation
|
||||
30
addons/client/functions/fnc_extractClientPosition.sqf
Normal file
30
addons/client/functions/fnc_extractClientPosition.sqf
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
/*
|
||||
* Author: Valmo Trindade
|
||||
* This function is used to extract the position of a unit and convert it to a format suitable for SIMTAK.
|
||||
*
|
||||
* Argument:
|
||||
* 0: The first argument <OBJECT> is the unit whose position you want to extract.
|
||||
*
|
||||
* Return Value:
|
||||
* ARRAY -> [latitude, longitude, altitude, bearing]
|
||||
*
|
||||
* Example:
|
||||
* [player] call armatak_client_fnc_extractClientPosition;
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
params["_unit"];
|
||||
|
||||
private _location = (getPos _unit) call armatak_client_fnc_convertClientLocation;
|
||||
|
||||
private _atak_latitude = _location select 0;
|
||||
private _atak_longitude = _location select 1;
|
||||
private _atak_altitude = _location select 2;
|
||||
private _atak_bearing = parseNumber ((getDir _unit) toFixed 0);
|
||||
|
||||
_unit_info = [_atak_latitude,_atak_longitude,_atak_altitude,_atak_bearing];
|
||||
|
||||
_unit_info
|
||||
11
addons/client/functions/fnc_socketRouter.sqf
Normal file
11
addons/client/functions/fnc_socketRouter.sqf
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
_local_address = "armatak" callExtension ["local_ip", []] select 0;
|
||||
|
||||
SETVAR(player, localAddress, _local_address);
|
||||
|
||||
[{
|
||||
"armatak" callExtension ["websocket:location", [player call FUNC(extractClientPosition)]];
|
||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
Reference in New Issue
Block a user