Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearm - Add event for rearm source creation #9134

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions addons/rearm/functions/fnc_makeSource.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ _source setVariable [QGVAR(currentSupply), _currentSupply + _rearmCargo, true];

private _rearmCargoConfig = getNumber (configOf _source >> QGVAR(defaultSupply));

// already initialized because this is a config rearm vehicle
if (_rearmCargoConfig > 0 || _source getVariable [QGVAR(isSupplyVehicle), false]) exitWith {};

_source setVariable [QGVAR(isSupplyVehicle), true, true];

// check if menu already exists
if (!isNil {_source getVariable QGVAR(initSupplyVehicle_jipID)}) exitWith {};
// initialize if it's not a config rearm vehicle
if (!(_rearmCargoConfig > 0 && _source getVariable [QGVAR(isSupplyVehicle), false])) then {
_source setVariable [QGVAR(isSupplyVehicle), true, true];

// only add if menu does not already exist
if (isNil {_source getVariable QGVAR(initSupplyVehicle_jipID)}) then {
private _jipID = [QGVAR(initSupplyVehicle), [_source]] call CBA_fnc_globalEventJIP;
[_jipID, _source] call CBA_fnc_removeGlobalEventJIP;
_source setVariable [QGVAR(initSupplyVehicle_jipID), _jipID];
};
};

private _jipID = [QGVAR(initSupplyVehicle), [_source]] call CBA_fnc_globalEventJIP;
[_jipID, _source] call CBA_fnc_removeGlobalEventJIP;
_source setVariable [QGVAR(initSupplyVehicle_jipID), _jipID];
[QGVAR(rearmSourceInitalized), [_source]] call CBA_fnc_globalEvent;
6 changes: 6 additions & 0 deletions docs/wiki/framework/rearm-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,9 @@ This function sets the current supply count of the ammo truck. It can be used to
---| --------- | -----------
0 | `ammo_truck` | My ammo truck object
1 | `1000`| Supply Count

## 4. Events

| Name | Arguments | Global? | Added in |
| ------------- | ------------- | ------------- |
| ace_rearm_sourceInitalized | Yes | Ammo truck (OBJECT) | 3.16.0 |