ACE3/addons/flags/functions/fnc_addActions.sqf

63 lines
1.4 KiB
Plaintext
Raw Normal View History

2022-06-10 19:46:06 +00:00
#include "script_component.hpp"
/*
* Author: Timi007
* Adds the child actions for placing and carring flags.
*
* Arguments:
* 0: Player <OBJECT>
*
* Return Value:
* Actions <ARRAY>
*
* Example:
* [player] call ace_flags_fnc_addActions
*
* Public: No
*/
params ["_player"];
private _actions = [];
{
2022-06-10 20:36:18 +00:00
(GVAR(flagItemCache) get _x) params ["_flagName", "_texture", "_actionIconPlace", "_actionIconCarry"];
2022-06-10 19:46:06 +00:00
// Place flag
_actions pushBack [
[
"place_" + _x,
2022-06-10 21:02:40 +00:00
format [LLSTRING(Place), _flagName],
2022-06-10 19:46:06 +00:00
_actionIconPlace,
2022-06-10 20:36:18 +00:00
{
params ["_player", "", "_item"];
[_player, _item] call FUNC(placeFlag);
},
{GVAR(enablePlacing)},
2022-06-10 19:46:06 +00:00
{},
_x
] call EFUNC(interact_menu,createAction),
[],
_player
];
// Carry flag
_actions pushBack [
[
"carry_" + _x,
2022-06-10 21:02:40 +00:00
format [LLSTRING(Carry), _flagName],
2022-06-10 19:46:06 +00:00
_actionIconCarry,
2022-06-10 20:36:18 +00:00
{
params ["_player", "", "_item"];
[_player, _item] call FUNC(carryFlag);
},
{GVAR(enableCarrying) && {!([_this select 0] call FUNC(carriesFlag))}}, // Should not carry flag already
2022-06-10 19:46:06 +00:00
{},
_x
] call EFUNC(interact_menu,createAction),
[],
_player
];
} forEach ([_player] call FUNC(getFlags));
_actions