Skip to content

Commit

Permalink
Added cScripts and loadout chat command to give you cscripts version …
Browse files Browse the repository at this point in the history
…and loadout name (#1211)
  • Loading branch information
AndreasBrostrom authored Jul 16, 2024
1 parent 821eb42 commit 3ff55ca
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions cScripts/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class cScripts {
// other
class gear_getLoadoutRole {};
class gear_getLoadoutName {};
class gear_getLoadoutDisplayName {};
};
class diag {
file = "cScripts\functions\diag";
Expand Down
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;

0 comments on commit 3ff55ca

Please sign in to comment.