Skip to content

Commit

Permalink
Merge branch 'main' into improvments-to-admin-and-curator-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBrostrom authored Jul 17, 2024
2 parents 550cb95 + 48c87eb commit 93a2db3
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cScripts/cScripts_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (EGVAR(Settings,showDiaryRecords)) then {
call EFUNC(civ,init);

onPlayerConnected {
[QEGVAR(log,player), [name player]] call CBA_fnc_serverEvent;
[QEGVAR(log,player), [getPlayerUID player, player]] call CBA_fnc_serverEvent;
};

INFO("postInit", "Initialization completed.");
30 changes: 26 additions & 4 deletions cScripts/functions/init/fn_init_eventHandlers.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,30 @@ INFO("InitEventHandlers","Creating Server EventHandlers");
}] call CBA_fnc_addEventHandler;

[QEGVAR(log,player), {
_this params ["_playerName"];
private _playerLog = missionNamespace getVariable [QEGVAR(log,players), []];
_playerLog pushBack _playerName;
missionNamespace setVariable [QEGVAR(log,players), _playerLog];
params ["_guid","_player"];
private _playerLog = GETMVAR(EGVAR(log,players),createHashMap);
INFO_3("PlayerLog","Connected %1 [%2] (GUID: %3)",name _player,typeOf _player,_guid);

if (!isNil{_playerLog get _guid}) then {
INFO_1("PlayerLog","Updating Log Entry [%1]", isNil{_playerLog get _guid});
private _data = _playerLog get _guid;

private _connections = _data get "connections";
_connections pushBack systemTimeUTC;
_data set ["connections", _connections];

_data set ["loadout", typeOf _player];

_playerLog set [_guid,_data];
} else {
INFO_1("PlayerLog", "Creating Log Entry [%1]", isNil{_playerLog get _guid});
private _entry = createHashMapFromArray [
['name', name _player],
['loadout', typeOf _player],
['connectTime', systemTimeUTC],
['connections', [systemTimeUTC]]
];
_playerLog set [_guid,_entry];
};
SETMVAR(EGVAR(log,players),_playerLog);
}] call CBA_fnc_addEventHandler;
74 changes: 54 additions & 20 deletions cScripts/functions/systems/fn_getAttendance.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,59 @@
*
*/

private _playerLog = missionNamespace getVariable [QEGVAR(log,players), []];
private _loggedPlayer = GETMVAR(EGVAR(log,players),[]);

// Rpt
["=================================================== START", "Attendance"] call FUNC(info);
[format ["Attendance (Entries: %1)", count _playerLog], "Attendance"] call FUNC(info);
private _header = format["=== Attendance (Entries: %1) ===", count _loggedPlayer];

private _dateTime = systemTimeUTC apply { if (_x < 10) then { "0" + str _x } else { str _x } };
private _formatDateTime = format["Date: %1-%2-%3 %4:%5z",_dateTime#0,_dateTime#1,_dateTime#2,_dateTime#3,_dateTime#4];

// Export
private _entries = [_header, endl, _formatDateTime, endl, endl];
{
_x params ["_name"];
[_name, "Attendance", false, false] call FUNC(info);
} forEach _playerLog;

["=================================================== END", "Attendence"] call FUNC(info);

// Hint
[
[],
["All attended players have been"],
["to your RPT log..."],
[""],
[""]
] call CBA_fnc_notify;

_playerLog
private _name = _y get "name";

private _loadout = _y get "loadout";
private _missionConfig = missionConfigFile >> "CfgLoadouts" >> _loadout;
private _displayName = getText (_missionConfig >> "displayName");
if (_displayName == "") then {
private _config = configFile >> "CfgLoadouts" >> _loadout;
_displayName = getText (_config >> "displayName");
};

private _connectTime = (_y get "connectTime") apply { if (_x < 10) then { "0" + str _x } else { str _x } };
private _formatConnectTime = format["%1-%2-%3 %4:%5z",_connectTime#0,_connectTime#1,_connectTime#2,_connectTime#3,_connectTime#4];

private _connections = count (_y get "connections");

_entries append [_name, " (", _displayName, ") ", _formatConnectTime, " (Connected ", str _connections, " time(s))", endl];
} forEach _loggedPlayer;

private _export = composeText _entries;
["Mission attendees", str _export] call zen_common_fnc_exportText;


// RPT
SHOW_INFO("Attendance",_header);
SHOW_INFO("Attendance",_formatDateTime);
{
private _name = _y get "name";

private _loadout = _y get "loadout";
private _missionConfig = missionConfigFile >> "CfgLoadouts" >> _loadout;
private _displayName = getText (_missionConfig >> "displayName");
if (_displayName == "") then {
private _config = configFile >> "CfgLoadouts" >> _loadout;
_displayName = getText (_config >> "displayName");
};

private _connectTime = (_y get "connectTime") apply { if (_x < 10) then { "0" + str _x } else { str _x } };
private _formatConnectTime = format["%1-%2-%3 %4:%5z",_connectTime#0,_connectTime#1,_connectTime#2,_connectTime#3,_connectTime#4];

private _connections = count (_y get "connections");

private _output = [_name, " (", _displayName, " [", _loadout,"]) ", _formatConnectTime, " (Connected ", str _connections, " time(s))"] joinString "";
SHOW_INFO("Attendance",_output);
} forEach _loggedPlayer;

SHOW_INFO("Attendance","================================");

0 comments on commit 93a2db3

Please sign in to comment.