ACE3/addons/intelitems/functions/fnc_addIntel.sqf
jonpas 6ca9d59443
Merge ACEX (#8415)
* Merge ACEX - first attempt
Backwards compatibility with XGVAR set of macros used on all settings and config entries
Public API functions not taken into account yet, many other things probably still missed

* Resolve issues

* Switch to addSetting, backward compatible CfgPatches, missed XGVAR.

* Remove unnecessary backwards compat

* Convert ACEX Categorised settings to initSettings / Fix Intel items magazine

* Apply suggestions from code review

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Remove maintainers from merged ACEX components

* Cleanup unused module and faction classes

* Sitting - Add more object configs by @Dystopian
https://github.com/acemod/ACEX/pull/255

* Translations - Add Japanese by @classicarma
https://github.com/acemod/ACEX/pull/259

* Kill Tracker - Add killtracker.inc public include file by @Freddo3000"
https://github.com/acemod/ACEX/pull/251

* Add ACEX authors and sort authors file

* acex - final tweaks (#8513)

* acex - handle old funcs

* replace thirst/hunger setvars to acex naming

fix macro

Revert "fix macro"

This reverts commit d807e5e804c43916eaa42d34a89af94c6d9a48ad.

Revert "replace thirst/hunger setvars to acex naming"

This reverts commit bafc607884932d6e339daedc7c22e25dddbdd868.

x

Co-authored-by: TyroneMF <TyroneMF@hotmail.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2021-10-14 10:46:43 -05:00

47 lines
1.3 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: mharis001
* Adds the given intel item (magazine) to the given unit.
* Must be called on the server.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Item <STRING>
* 3: Data <STRING>
*
* Return Value:
* Successful <BOOL>
*
* Example:
* [_unit, "acex_intelitems_notepad", "Notes!"] call ace_intelitems_fnc_addIntel
*
* Public: Yes
*/
if (canSuspend) exitWith {
[FUNC(addIntel), _this] call CBA_fnc_directCall;
};
params [["_unit", objNull, [objNull]], ["_item", "", [""]], ["_data", "", [""]]];
if (
!isServer
|| {!(_unit isKindOf "CAManBase")}
|| {!(_unit canAdd _item)}
|| {getNumber (configFile >> "CfgMagazines" >> _item >> QGVAR(intel)) != 1}
) exitWith { ERROR_1("addIntel failed - %1",_this); false };
// Add the magazine item to the unit's inventory and get its id
private _magazinesBefore = [_unit, _item] call CBA_fnc_getMagazineIndex;
_unit addMagazine [_item, 1];
private _magazinesAfter = [_unit, _item] call CBA_fnc_getMagazineIndex;
private _magazineId = _magazinesAfter - _magazinesBefore;
if (_magazineId isEqualTo []) exitWith {false};
// Assign an intel index to the added magazine id and set its data
private _index = [_magazineId select 0] call FUNC(handleMagIndex);
SET_DATA(_index,_data);
true