Skip to content

Commit

Permalink
Merge branch 'main' into removedTaggingSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBrostrom authored Jul 17, 2024
2 parents 805e121 + b186778 commit aa731ed
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 157 deletions.
3 changes: 2 additions & 1 deletion cScripts/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class cScripts {
class player_getRole {};

class player_isCurator {};

class player_isMissionAdmin {};
class unit_setTeamColor {};

class unit_getName {};
Expand Down Expand Up @@ -244,6 +244,7 @@ class cScripts {
// other
class gear_getLoadoutRole {};
class gear_getLoadoutName {};
class gear_getLoadoutDisplayName {};
};
class diag {
file = "cScripts\functions\diag";
Expand Down
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: 30 additions & 0 deletions cScripts/functions/gear/fn_gear_getLoadoutDisplayName.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "..\script_component.hpp"
/*
* Author: CPL.Brostrom.A
* This function return a units current loadouts displayname.
*
* Arguments:
* 0: Unit <Object>
*
* Return Value:
* Loadout name <STRING>
*
* Example:
* [player] call cScripts_fnc_gear_getLoadoutDisplayName;
* [cursorObject] call cScripts_fnc_gear_getLoadoutDisplayName;
*
*/

params [["_unit", objNull, [objNull]]];

private _loadout = [_unit] call EFUNC(gear,getLoadoutName);

private _missionConfig = missionConfigFile >> "CfgLoadouts" >> _loadout;
private _displayName = getText (_missionConfig >> "displayName");

if (_displayName == "") then {
private _config = configFile >> "CfgLoadouts" >> _loadout;
_displayName = getText (_config >> "displayName");
};

_displayName
11 changes: 11 additions & 0 deletions cScripts/functions/init/fn_init_chatCommands.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@
["attendance", {
[QGVAR(getAttendance)] call CBA_fnc_localEvent;
}, "all"] call CBA_fnc_registerChatCommand;

// Help and diagnostic commands
["cScripts", {
systemChat format["cScripts version: %1", VERSION];
}, "all"] call CBA_fnc_registerChatCommand;

["loadout", {
private _name = [player] call EFUNC(gear,getLoadoutDisplayName);
private _loadout = [player] call EFUNC(gear,getLoadoutName);
systemChat format["Your current loadout is: %1 [%2]",_name,_loadout];
}, "all"] call CBA_fnc_registerChatCommand;
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;
4 changes: 3 additions & 1 deletion cScripts/functions/players/fn_player_isCurator.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
* true/False <BOOLEAN>
*
* Example:
* call cScripts_fnc_unit_isCurator
* call cScripts_fnc_player_isCurator
*
*/

if (!isNull (getAssignedCuratorLogic player)) exitWith {true};

private _curator = player getVariable [QEGVAR(Player,Unit), ""];
_curator = toLower _curator;
if (_curator == "s3") exitWith {true};
Expand Down
21 changes: 21 additions & 0 deletions cScripts/functions/players/fn_player_isMissionAdmin.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "..\script_component.hpp";
/*
* Author: SGT.Brostrom.A
* This function return true if a player is curator or admin
*
* Arguments:
* None
*
* Return Value:
* True/False <BOOLEAN>
*
* Example:
* call cScripts_fnc_player_isMissionAdmin
*
*/

if (!isNull (getAssignedCuratorLogic player)) exitWith {true};
if (call BIS_fnc_admin > 1) exitWith {true};
if (!isMultiplayer || {is3DENMultiplayer}) exitWith {true};

false
1 change: 1 addition & 0 deletions cScripts/functions/systems/fn_allowLoadout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if (EGVAR(Staging,showAllLoadouts)) exitWith {true};

// Check if player is Zeus or Debug
if (call EFUNC(player,isCurator)) exitWith {true};
if (call EFUNC(player,isMissionAdmin)) exitWith {true};

// Check if does not have any company
private _playerCompany = call EFUNC(player,getCompany);
Expand Down
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","================================");
Loading

0 comments on commit aa731ed

Please sign in to comment.