mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 14:33:56 +00:00
Added whole websocket handling to the client addon
This commit is contained in:
1
addons/client/$PBOPREFIX$
Normal file
1
addons/client/$PBOPREFIX$
Normal file
@@ -0,0 +1 @@
|
||||
armatak\armatak\armatak_client
|
||||
11
addons/client/CfgEventHandlers.hpp
Normal file
11
addons/client/CfgEventHandlers.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
class Extended_PreStart_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit));
|
||||
};
|
||||
};
|
||||
3
addons/client/XEH_PREP.hpp
Normal file
3
addons/client/XEH_PREP.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
PREP(convertLocation);
|
||||
PREP(extractClientPosition);
|
||||
PREP(socketRouter);
|
||||
9
addons/client/XEH_preInit.sqf
Normal file
9
addons/client/XEH_preInit.sqf
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP_RECOMPILE_START;
|
||||
#include "XEH_PREP.hpp"
|
||||
PREP_RECOMPILE_END;
|
||||
|
||||
ADDON = true;
|
||||
3
addons/client/XEH_preStart.sqf
Normal file
3
addons/client/XEH_preStart.sqf
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
#include "XEH_PREP.hpp"
|
||||
@@ -21,3 +21,5 @@ class Extended_PostInit_EventHandlers {
|
||||
init = "call compileScript ['\armatak\armatak\armatak_client\initPlayerLocal.sqf']";
|
||||
};
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
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;
|
||||
@@ -1,18 +0,0 @@
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
_local_address = "armatak" callExtension ["local_ip", []] select 0;
|
||||
|
||||
player setVariable ["localAddress", _local_address];
|
||||
|
||||
player addEventHandler ["Respawn", {
|
||||
params["_unit", "_corpse"];
|
||||
[{
|
||||
if (alive _this) then {
|
||||
"armatak" callExtension ["websocket:location", [player call armatak_fnc_extract_position]];
|
||||
};
|
||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
}];
|
||||
|
||||
[{
|
||||
"armatak" callExtension ["websocket:location", [player call armatak_fnc_extract_position]];
|
||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
@@ -1,17 +1,17 @@
|
||||
#define COMPONENT client
|
||||
#define COMPONENT_BEAUTIFIED WebSocket
|
||||
#define COMPONENT_BEAUTIFIED WebSocket Client
|
||||
#include "\armatak\armatak\armatak_main\script_mod.hpp"
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
// #define DISABLE_COMPILE_CACHE
|
||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||
|
||||
#ifdef DEBUG_ENABLED_MAIN
|
||||
#ifdef DEBUG_ENABLED_CLIENT
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SETTINGS_MAIN
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN
|
||||
#ifdef DEBUG_SETTINGS_CLIENT
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_CLIENT
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
||||
|
||||
Reference in New Issue
Block a user