-
Notifications
You must be signed in to change notification settings - Fork 737
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Arsenal - Add
ace_arsenal_fnc_saveLoadout
as API to save loadouts (#…
…10151) * Added fnc_saveLoadout * Changed to toLower for other languages * GitHub didn't like editing the file in the browser * Fix case-sensitive _loadoutIndex Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * Unicode support Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * setVariable in case no loadouts are saved * Fix return not happening properly * Added scripting example * Update docs/wiki/framework/arsenal-framework.md --------- Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
- Loading branch information
1 parent
346d56c
commit e36363e
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: DartRuffian | ||
* Saves a given loadout to the client's profile. | ||
* | ||
* Arguments: | ||
* 0: Name of loadout <STRING> | ||
* 1: CBA extended loadout or getUnitLoadout array <ARRAY> | ||
* 2: Replace existing loadout <BOOL> (default: false) | ||
* | ||
* Return Value: | ||
* True if loadout was saved, otherwise false <BOOL> | ||
* | ||
* Example: | ||
* ["Current Loadout", getUnitLoadout ACE_player] call ace_arsenal_fnc_saveLoadout | ||
* | ||
* Public: Yes | ||
*/ | ||
|
||
params [["_name", "", [""]], ["_loadout", [], [[]]], ["_replaceExisting", false, [false]]]; | ||
|
||
if (_name == "" || {_loadout isEqualTo []}) exitWith { false }; | ||
|
||
private _loadouts = profileNamespace getVariable [QGVAR(saved_loadouts), []]; | ||
private _loadoutIndex = _loadouts findIf {(_x#0) == _name}; | ||
|
||
// If a loadout with same name already exists and no overwriting enabled, quit | ||
if (!_replaceExisting && {_loadoutIndex != -1}) exitWith { false }; | ||
|
||
if (_loadoutIndex == -1) then { | ||
_loadouts pushBack [_name, _loadout]; | ||
} else { | ||
_loadouts set [_loadoutIndex, [_name, _loadout]]; | ||
}; | ||
|
||
profileNamespace setVariable [QGVAR(saved_loadouts), _loadouts]; | ||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters