This is the entry point for my jetpack system, it runs a few checks (player not in water, player has fuel, etc.
private _jetpack = backpack ace_player;
private _jetStrength = GET_NUMBER(configFile >> "CfgVehicles" >> _jetpack >> "BNA_KC_Jet_strength", 1);
if (isNil "BNA_KC_Jet_JetpackHandle") then
{
private _velocity = velocity ace_player;
private _position = getPosASL ace_player;
if (ace_player call BNAKC_fnc_CanUseJetpack and isTouchingGround ace_player) then
{
};
["BNA_KC_Jet_JetpackFired", [ace_player]] call CBA_fnc_GlobalEvent;
BNA_KC_Jet_JetpackHandle =
[
BNAKC_fnc_JetpackFrameHandler
] call CBA_fnc_AddPerFrameHandler;
}
private _thisHandler = _this select 1;
if (!(ace_player call BNAKC_fnc_CanUseJetpack) or isTouchingGround ace_player) exitWith
{
[_thisHandler] call CBA_fnc_removePerFrameHandler;
BNA_KC_Jet_JetpackHandle = nil;
[BNA_KC_Jet_JetpackFuelHandle] call CBA_fnc_removePerFrameHandler;
BNA_KC_Jet_JetpackFuelHandle = nil;
[
{
{
deleteVehicle _x;
} forEach (ace_player getVariable ["BNA_KC_Jet_effectSources", []]);
[BNA_KC_Jet_JetpackSoundHandle] call CBA_fnc_removePerFrameHandler;
BNA_KC_Jet_JetpackSoundHandle = nil;
},
[],
0.3
] call CBA_fnc_waitAndExecute;
};
if !(hasInterface) exitwith {};
params ["_unit"];
if (!(_unit call BNAKC_fnc_CanUseJetpack) or isTouchingGround _unit) exitWith {};
private _effectPoints = GET_ARRAY(configFile >> "CfgVehicles" >> _jetpack >> "BNA_KC_Jet_effectPoints", []);
{
} forEach _effectPoints;
_unit setVariable ["BNA_KC_Jet_effectSources", _effectSources];