mirror of
https://github.com/indig0fox/Arma3-AttendanceTracker.git/
synced 2025-12-08 09:51:47 -06:00
add hemtt support, major refactor
- no longer supports server events - can now more easily build using hemtt - extension vastly improved in both structure and functionality - tested on listen server - includes schema change
This commit is contained in:
61
addons/main/functions/fn_postInit.sqf
Normal file
61
addons/main/functions/fn_postInit.sqf
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "..\script_mod.hpp"
|
||||
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
ATNamespace = false call CBA_fnc_createNamespace;
|
||||
ATDebug = true;
|
||||
"AttendanceTracker" callExtension ":START:";
|
||||
|
||||
|
||||
// we'll wait for the asynchronous init steps of the extension to finish, to confirm we have a DB connection and our config was loaded. If there are errors with either, the extension won't reply and initiate further during this mission.
|
||||
addMissionEventHandler ["ExtensionCallback", {
|
||||
params ["_name", "_function", "_data"];
|
||||
if !(_name isEqualTo "AttendanceTracker") exitWith {};
|
||||
if !(_function isEqualTo ":READY:") exitWith {};
|
||||
|
||||
call attendanceTracker_fnc_getMissionHash;
|
||||
call attendanceTracker_fnc_getSettings;
|
||||
|
||||
[
|
||||
{// wait until settings have been loaded from extension
|
||||
!isNil {ATNamespace getVariable "missionHash"} &&
|
||||
!isNil {ATDebug}
|
||||
},
|
||||
{
|
||||
|
||||
// get world and mission context
|
||||
ATNamespace setVariable [
|
||||
"worldContext",
|
||||
call attendanceTracker_fnc_getWorldInfo
|
||||
];
|
||||
ATNamespace setVariable [
|
||||
"missionContext",
|
||||
call attendanceTracker_fnc_getMissionInfo
|
||||
];
|
||||
|
||||
// write them to establish DB rows
|
||||
"AttendanceTracker" callExtension [
|
||||
":LOG:MISSION:",
|
||||
[
|
||||
[ATNamespace getVariable "missionContext"] call CBA_fnc_encodeJSON,
|
||||
[ATNamespace getVariable "worldContext"] call CBA_fnc_encodeJSON
|
||||
]
|
||||
];
|
||||
|
||||
// add player connected (to mission) handler
|
||||
addMissionEventHandler ["PlayerConnected", {
|
||||
_this call attendanceTracker_fnc_onPlayerConnected;
|
||||
}];
|
||||
},
|
||||
[],
|
||||
10, // 10 second timeout
|
||||
{ // timeout code
|
||||
["Failed to load settings", "ERROR"] call attendanceTracker_fnc_log;
|
||||
}
|
||||
] call CBA_fnc_waitUntilAndExecute;
|
||||
|
||||
removeMissionEventHandler [
|
||||
"ExtensionCallback",
|
||||
_thisEventHandler
|
||||
];
|
||||
}];
|
||||
Reference in New Issue
Block a user