diff --git a/addons/main/config.cpp b/addons/main/config.cpp
index dfb6909..afd8d31 100644
--- a/addons/main/config.cpp
+++ b/addons/main/config.cpp
@@ -16,5 +16,11 @@ class CfgPatches {
};
};
+class Extended_PostInit_EventHandlers {
+ class armatak_main {
+ init = "call compileScript ['\armatak\armatak\armatak_main\initPlayerLocal.sqf']";
+ };
+};
+
#include "CfgFunctions.hpp"
#include "CfgVehicles.hpp"
\ No newline at end of file
diff --git a/addons/main/functions/fn_init.sqf b/addons/main/functions/fn_init.sqf
index 848f69e..809ea8f 100644
--- a/addons/main/functions/fn_init.sqf
+++ b/addons/main/functions/fn_init.sqf
@@ -3,69 +3,3 @@ params [
["_units", [], [[]]],
["_activated", true, [true]]
];
-/*
- if (isServer && _activated) exitWith {
- private _warning = format ["ARMATAK
%1", "Connecting..."];
- [[_warning, 1.5]] call CBA_fnc_notify;
-
- _atak_ots_address = _logic getVariable "armatak_module_ots_api_instance_address";
- _atak_ots_protocol = _logic getVariable "armatak_module_ots_api_instance_protocol";
- _atak_ots_port = _logic getVariable "armatak_module_ots_api_instance_port";
-
- _atak_ots_fulladdress = _atak_ots_protocol + ":" + "/" + "/" + _atak_ots_address + ":" + (str _atak_ots_port);
- _atak_ots_api_username = _logic getVariable "armatak_module_ots_api_instance_username";
- _atak_ots_api_password = _logic getVariable "armatak_module_ots_api_instance_password";
-
- missionNamespace setVariable ["_atak_server_instance", _atak_ots_fulladdress];
- missionNamespace setVariable ["_atak_server_instance_username", _atak_ots_api_username];
- missionNamespace setVariable ["_atak_server_instance_password", _atak_ots_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;
- } else {
- private _warning = format ["ARMATAK
%1", "Connected"];
- [[_warning, 2]] call CBA_fnc_notify;
- };
-
- [{
- if (isMultiplayer) then {
- [{
- _markers = [];
-
- {
- private _unit = _x;
- _m = _unit call armatak_fnc_extract_info;
- _markers append [_m];
- } forEach playableUnits;
- {
- private _unit = _x;
- if (_unit getVariable "_atak_uav_connected") then {
- _m = _unit call armatak_fnc_extract_drone_info;
- _markers append [_m];
- };
- } forEach allUnitsUAV;
- [_markers] call armatak_fnc_postMarkers;
- }, 1, []] call CBA_fnc_addPerFrameHandler;
- } else {
- [{
- _markers = [];
-
- _m = player call armatak_fnc_extract_info;
- _markers append [_m];
-
- {
- if (_x getVariable "_atak_uav_connected") then {
- _m = _x call armatak_fnc_extract_drone_info;
- _markers append [_m];
- };
- } forEach allUnitsUAV;
- [_markers] call armatak_fnc_postMarkers;
- }, 1, []] call CBA_fnc_addPerFrameHandler;
- };
- }, [], 1] call CBA_fnc_waitAndExecute;
- };
-
- */
\ No newline at end of file
diff --git a/addons/main/initPlayerLocal.sqf b/addons/main/initPlayerLocal.sqf
new file mode 100644
index 0000000..5f64af0
--- /dev/null
+++ b/addons/main/initPlayerLocal.sqf
@@ -0,0 +1,39 @@
+if (!hasInterface) exitWith {};
+
+_initializedServer = "armatak" callExtension ["start",[]] select 0;
+_local_address = "armatak" callExtension ["local_ip", []] select 0;
+
+player setVariable ["initializedSocket", _initializedServer];
+player setVariable ["localAddress", _local_address];
+
+waitUntil {alive player};
+
+[{
+ if (alive player) then {
+ "armatak" callExtension ["location",[player call armatak_fnc_extract_info]];
+ };
+}, 1, []] call CBA_fnc_addPerFrameHandler;
+
+player addEventHandler ["Killed", {
+ "armatak" callExtension ["stop", []];
+}];
+
+player addEventHandler ["Deleted", {
+ "armatak" callExtension ["stop", []];
+}];
+
+player addEventHandler ["Respawn", {
+ params["_unit", "_corpse"];
+
+ _unit spawn {
+ "armatak" callExtension ["start", []];
+
+ [{
+ if (alive _this) then {
+ "armatak" callExtension ["location",[player call armatak_fnc_extract_info]];
+ };
+ }, 1, []] call CBA_fnc_addPerFrameHandler;
+ };
+}];
+
+onPlayerDisconnected "'armatak' callExtension ['stop',[]];";
\ No newline at end of file