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

Refuel - Add events for fuel source and jerry can creation #9133

Merged
merged 3 commits 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
7 changes: 5 additions & 2 deletions addons/refuel/functions/fnc_makeJerryCan.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ if (isNull _target ||

_target setVariable [QGVAR(jerryCan), true];
_target setVariable [QGVAR(source), _target];

_target setVariable [QGVAR(capacity), _fuelAmount];
if (isServer) then { [_target, _fuelAmount] call FUNC(setFuel); };

if (isServer) then {
[_target, _fuelAmount] call FUNC(setFuel); // has global effects
[QVAR(jerryCanInitalized), [_target]] call CBA_fnc_globalevent;
};

// Main Action
private _action = [QGVAR(Refuel),
Expand Down
12 changes: 7 additions & 5 deletions addons/refuel/functions/fnc_makeSource.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ if (
_source setVariable [QGVAR(hooks), _hooks, true];
};

// check if menu already exists
if (_fuelCargoConfig != 0 || {!isNil {_source getVariable QGVAR(initSource_jipID)}}) exitWith {};
// only add if menu doesn't already exist
if (!(_fuelCargoConfig != 0 && {!isNil {_source getVariable QGVAR(initSource_jipID)}})) then {
private _jipID = [QGVAR(initSource), [_source]] call CBA_fnc_globalEventJIP;
[_jipID, _source] call CBA_fnc_removeGlobalEventJIP;
_source setVariable [QGVAR(initSource_jipID), _jipID];
};

private _jipID = [QGVAR(initSource), [_source]] call CBA_fnc_globalEventJIP;
[_jipID, _source] call CBA_fnc_removeGlobalEventJIP;
_source setVariable [QGVAR(initSource_jipID), _jipID];
[QGVAR(sourceInitialized), [_source]] call CBA_fnc_globalEvent;
7 changes: 7 additions & 0 deletions docs/wiki/framework/refuel-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,10 @@ The jerry can will now have a volume of 200 liters.
---| --------- | -----------
0 | `cursorObject` | Fuel source object
1 | `100` | Fuel supply

## 3. Events

| Name | Arguments | Global? | Added in |
| ------------- | ------------- | ------------- |
| ace_refuel_sourceInitialized | Fuel source (OBJECT), items (BOOL or ARRAY) | Yes | 3.16.0 |
| ace_refuel_jerryCanInitalized | Jerry can (OBJECT) | Yes | 3.16.0 |