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

add Group and Leader Changed Player Event #703

Merged
merged 1 commit into from
Jun 24, 2017
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
28 changes: 28 additions & 0 deletions addons/events/fnc_addPlayerEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Description:
"visionMode" - player changed to normal/night/thermal view
"cameraView" - camera mode changed ("Internal", "External", "Gunner" etc.)
"visibleMap" - opened or closed map
"group" - player group changes
"leader" - leader of player changes

Parameters:
_type - Event handler type. <STRING>
Expand Down Expand Up @@ -88,6 +90,18 @@ case "visiblemap": {
};
[QGVAR(visibleMapEvent), _function] call CBA_fnc_addEventHandler // return id
};
case "group": {
if (_applyRetroactively && {!isNull (missionNamespace getVariable [QGVAR(oldUnit), objNull])}) then {
[GVAR(oldUnit), group GVAR(oldUnit)] call _function;
};
[QGVAR(groupEvent), _function] call CBA_fnc_addEventHandler // return id
};
case "leader": {
if (_applyRetroactively && {!isNull (missionNamespace getVariable [QGVAR(oldUnit), objNull])}) then {
[GVAR(oldUnit), group GVAR(oldUnit)] call _function;
};
[QGVAR(leaderEvent), _function] call CBA_fnc_addEventHandler // return id
};
default {-1};
};

Expand All @@ -97,6 +111,8 @@ if (_id != -1) then {
GVAR(playerEHInfo) = [];

GVAR(oldUnit) = objNull;
GVAR(oldGroup) = grpNull;
GVAR(oldLeader) = objNull;
GVAR(oldWeapon) = "";
GVAR(oldLoadout) = [];
GVAR(oldLoadoutNoAmmo) = [];
Expand All @@ -114,6 +130,18 @@ if (_id != -1) then {
GVAR(oldUnit) = _player;
};

private _data = group _player;
Copy link
Contributor

@dedmen dedmen Jun 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why re-private _data ? Line 151 is not doing that. In the old version only the first _data assignment was privated

if !(_data isEqualTo GVAR(oldGroup)) then {
[QGVAR(groupEvent), [_player, GVAR(oldGroup)]] call CBA_fnc_localEvent;
GVAR(oldGroup) = _data;
};

private _data = leader _player;
if !(_data isEqualTo GVAR(oldLeader)) then {
[QGVAR(leaderEvent), [_player, GVAR(oldLeader)]] call CBA_fnc_localEvent;
GVAR(oldLeader) = _data;
};

private _data = currentWeapon _player;
if !(_data isEqualTo GVAR(oldWeapon)) then {
GVAR(oldWeapon) = _data;
Expand Down
6 changes: 6 additions & 0 deletions addons/events/fnc_removePlayerEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ case "cameraview": {
case "visiblemap": {
[QGVAR(visibleMapEvent), _id] call CBA_fnc_removeEventHandler;
};
case "group": {
[QGVAR(groupEvent), _id] call CBA_fnc_removeEventHandler;
};
case "leader": {
[QGVAR(leaderEvent), _id] call CBA_fnc_removeEventHandler;
};
default {nil};
};

Expand Down