From 3ff55ca98805bdf955c3c4f37d0cbaf5877730a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brostr=C3=B6m=2EA=20=7C=20Evul?= Date: Tue, 16 Jul 2024 17:56:52 +0200 Subject: [PATCH] Added cScripts and loadout chat command to give you cscripts version and loadout name (#1211) --- cScripts/CfgFunctions.hpp | 1 + .../gear/fn_gear_getLoadoutDisplayName.sqf | 30 +++++++++++++++++++ .../functions/init/fn_init_chatCommands.sqf | 11 +++++++ 3 files changed, 42 insertions(+) create mode 100644 cScripts/functions/gear/fn_gear_getLoadoutDisplayName.sqf diff --git a/cScripts/CfgFunctions.hpp b/cScripts/CfgFunctions.hpp index 601233a2b..da9d39b66 100644 --- a/cScripts/CfgFunctions.hpp +++ b/cScripts/CfgFunctions.hpp @@ -245,6 +245,7 @@ class cScripts { // other class gear_getLoadoutRole {}; class gear_getLoadoutName {}; + class gear_getLoadoutDisplayName {}; }; class diag { file = "cScripts\functions\diag"; diff --git a/cScripts/functions/gear/fn_gear_getLoadoutDisplayName.sqf b/cScripts/functions/gear/fn_gear_getLoadoutDisplayName.sqf new file mode 100644 index 000000000..b7f7d9ae7 --- /dev/null +++ b/cScripts/functions/gear/fn_gear_getLoadoutDisplayName.sqf @@ -0,0 +1,30 @@ +#include "..\script_component.hpp" +/* + * Author: CPL.Brostrom.A + * This function return a units current loadouts displayname. + * + * Arguments: + * 0: Unit + * + * Return Value: + * Loadout name + * + * 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 \ No newline at end of file diff --git a/cScripts/functions/init/fn_init_chatCommands.sqf b/cScripts/functions/init/fn_init_chatCommands.sqf index 6e6a218bc..0de2c7c77 100644 --- a/cScripts/functions/init/fn_init_chatCommands.sqf +++ b/cScripts/functions/init/fn_init_chatCommands.sqf @@ -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;