ACE3/addons/explosives/functions/fnc_addToSpeedDial.sqf

41 lines
828 B
Plaintext
Raw Normal View History

/*
* Author: Garth 'L-H' de Wet
* Sets the speed dial for the UI.
*
* Arguments:
* 0: Name of speed dial <STRING>
* 1: Code to add to speed dial <STRING>
*
* Return Value:
* None
*
* Example:
* ["My Speed Dial","2131"] call ACE_explosives_fnc_addToSpeedDial;
*
* Public: Yes
*/
#include "script_component.hpp"
2015-08-15 19:35:33 +00:00
params ["_name", "_code"];
TRACE_2("params",_name,_code);
private ["_speedDial", "_found"];
2015-08-15 19:35:33 +00:00
_speedDial = ace_player getVariable [QGVAR(SpeedDial), []];
_found = false;
2015-08-15 19:35:33 +00:00
if ((_code) == "") exitWith {
[_name] call FUNC(removeFromSpeedDial);
};
{
if ((_x select 0) == _name) exitWith {
_speedDial set [_foreachindex, _this];
_found = true;
};
2015-08-15 19:35:33 +00:00
} forEach _speedDial;
if (!_found) then {
_speedDial pushBack _this;
};
ace_player setVariable [QGVAR(SpeedDial), _speedDial];