Skip to content

Instantly share code, notes, and snippets.

@commy2
Created March 12, 2019 20:41
Show Gist options
  • Save commy2/21970af50cfe3cdc4c40e3ab022df74b to your computer and use it in GitHub Desktop.
Save commy2/21970af50cfe3cdc4c40e3ab022df74b to your computer and use it in GitHub Desktop.
// init.sqf
commy_assembledStaticWeapons = [];
["StaticWeapon", "initPost", {
params ["_static"];
commy_assembledStaticWeapons pushBack _static;
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
["CAManBase", "WeaponAssembled", {
params ["_unit", "_static"];
commy_assembledStaticWeapons pushBackUnique _static;
}] call CBA_fnc_addClassEventHandler;
["CAManBase", "WeaponDisassembled", {
params ["_unit", "_bag1", "_bag2"];
commy_assembledStaticWeapons = commy_assembledStaticWeapons select {!isNull _x};
private _static = (commy_assembledStaticWeapons - entities "") param [0, objNull];
if (isNull _static) exitWith {};
commy_assembledStaticWeapons deleteAt (commy_assembledStaticWeapons find _static);
_bag1 setVariable ["commy_staticWeapon", _static];
_bag2 setVariable ["commy_staticWeapon", _static];
}] call CBA_fnc_addClassEventHandler;
commy_fnc_getAmmoFromBag = {
params ["_bag"];
private _static = _bag getVariable ["commy_staticWeapon", objNull];
_static ammo currentWeapon _static
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment