Skip to content
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
1 change: 1 addition & 0 deletions addons/recorder/XEH_prep.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ PREP(addUnitEventHandlers);
PREP(eh_connected);
PREP(eh_disconnected);
PREP(eh_onUserAdminStateChanged);
PREP(eh_onUserSelectedPlayer);
PREP(adminUIcontrol);

PREP(eh_firedMan);
Expand Down
9 changes: 9 additions & 0 deletions addons/recorder/fnc_addEventMission.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ if (isNil QEGVAR(EH,OnUserAdminStateChanged)) then {
OCAPEXTLOG(["Initialized OnUserAdminStateChanged EH"]);
};

if (isNil QEGVAR(EH,OnUserSelectedPlayer)) then {
// Event Handler: OCAP_EH_OnUserSelectedPlayer
// Handle for the "OnUserSelectedPlayer" mission event handler. Fired when a player object is selected for user. Calls <OCAP_recorder_fnc_eh_onUserSelectedPlayer>.
EGVAR(EH,OnUserSelectedPlayer) = addMissionEventHandler ["OnUserSelectedPlayer", {
_this call FUNC(eh_onUserSelectedPlayer);
}];
OCAPEXTLOG(["Initialized OnUserSelectedPlayer EH"]);
};

if (isNil QEGVAR(EH,EntityKilled)) then {
// Event Handler: OCAP_EH_EntityKilled
// Handle for the "EntityKilled" mission event handler. Fired when an entity is killed. Calls <OCAP_recorder_fnc_eh_killed>.
Expand Down
2 changes: 1 addition & 1 deletion addons/recorder/fnc_adminUIcontrol.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Description:
Runs checks to determine if a player should have the administrative diary entry added or removed upon joining the mission or logging in/out as admin.

- <OCAP_recorder_fnc_eh_connected> at mission start to determine if a player is in <OCAP_administratorList>
- <OCAP_recorder_fnc_eh_onUserAdminStateChanged> to add/remove when a player logs in or out as admin on the server
- <OCAP_recorder_fnc_eh_onUserSelectedPlayer> at mission start to determine if a player is in <OCAP_administratorList>

Parameters:
_PID - PlayerID indicating unique network client on the server [String]
Expand Down
5 changes: 0 additions & 5 deletions addons/recorder/fnc_eh_connected.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

This function uses the <OCAP_EH_Connected> event handler to log "connected" events to the timeline.

It also calls <OCAP_recorder_fnc_adminUIControl> to apply the admin UI if the player is in <OCAP_administratorList>.

Parameters:
See the wiki for details. <https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#PlayerConnected>

Expand Down Expand Up @@ -40,6 +38,3 @@ if (_owner isEqualTo 2) exitWith {};
["playerUid", _uid]
]] call CBA_fnc_encodeJSON
]] call EFUNC(extension,sendData);

// trigger admin control check for all connecting players
[_idstr, "connect"] call FUNC(adminUIcontrol);
50 changes: 50 additions & 0 deletions addons/recorder/fnc_eh_onUserSelectedPlayer.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* ----------------------------------------------------------------------------
FILE: fnc_eh_onUserSelectedPlayer.sqf

FUNCTION: OCAP_recorder_fnc_eh_onUserSelectedPlayer

Description:
Uses <OCAP_EH_OnUserSelectedPlayer> to detect when someone joins the server.

Calls <OCAP_recorder_fnc_adminUIControl> to apply the admin UI if the player is in <OCAP_administratorList>.

Parameters:
_networkId - The network ID of the player who has logged in or out of the server [String]
_playerObject - player object to be controlled by the user [Object]

Returns:
Nothing

Examples:
> call FUNC(eh_onUserSelectedPlayer);

Public:
No

Author:
IndigoFox
---------------------------------------------------------------------------- */
#include "script_component.hpp"

params ["_networkId", "_playerObject"];

// For non-JIP players, OnUserSelectedPlayer fires between preInit and postInit. Since we're initializing in postInit, this function will be too late to handle non-JIP players. Admins in this case are handled by <OCAP_recorder_fnc_init>.
if (!isNull _playerObject) exitWith {
_playerObject addEventHandler ["Local", {
params ["_playerObject"];
_playerObject removeEventHandler [_thisEvent, _thisEventHandler];

private _networkId = getPlayerID _playerObject;
[_networkId, "connect"] call FUNC(adminUIcontrol);
}];
};

// In rare cases, _playerObject may be objNull despite Arma 3 v2.18 allowing the event to be postponed.
// Make a last ditch attempt to wait for the player object to be set (similar to <OCAP_recorder_fnc_init>).
[{
!isNull (getUserInfo _this param [10, objNull, [objNull]])
}, {
[_this, "connect"] call FUNC(adminUIcontrol);
}, _networkId, 30, {
diag_log text format ["[OCAP] (recorder) WARNING: connecting player object is null for PID: %1", _this];
}] call CBA_fnc_waitUntilAndExecute;
5 changes: 2 additions & 3 deletions addons/recorder/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ call FUNC(eh_fired_server);
call FUNC(telemetryLoop);
[] spawn FUNC(getStaticObjects);

// Check already-connected players for admin controls (fixes race condition
// where players connected before OCAP initialized don't get diary entries)
// Check non-JIP players for admin controls, as postInit is too late for <OCAP_recorder_fnc_eh_onUserSelectedPlayer> to fire.
// Wait for getUserInfo to be populated before calling, as it may not be ready during postInit
{
private _pid = str owner _x;
private _pid = getPlayerID _x;
[{
private _info = getUserInfo _this;
!isNil "_info" && {_info isEqualType [] && {count _info >= 11}}
Expand Down