forked from IDI-Systems/acre2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnc_stopUsingExternalRadio.sqf
45 lines (38 loc) · 1.79 KB
/
fnc_stopUsingExternalRadio.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "script_component.hpp"
/*
* Author: ACRE2Team
* Stop using an external radio, either returning it to the owner or giving it to another player. If target
* is skipped, a default action to return to the owner is taken.
*
* Arguments:
* 0: Unique radio identity <STRING>
* 1: New end user/original owner <OBJECT>
*
* Return Value:
* None
*
* Example:
* ["ACRE_PRC343_ID_1", cursorTarget] call acre_sys_external_fnc_stopUsingExternalRadio
*
* Public: No
*/
params ["_radioId", "_target"];
private _owner = [_radioId] call FUNC(getExternalRadioOwner);
ACRE_ACTIVE_EXTERNAL_RADIOS = ACRE_ACTIVE_EXTERNAL_RADIOS - [_radioId];
[_radioId] call EFUNC(sys_radio,stopUsingRadio);
private _baseRadio = [_radioId] call EFUNC(api,getBaseRadio);
private _displayName = getText (configFile >> "CfgWeapons" >> _baseRadio >> "displayName");
[[ICON_RADIO_CALL], [format [localize LSTRING(hintReturn), _displayName, name _owner]], true] call CBA_fnc_notify;
if (_target == _owner) then {
// Handle remote owner
private _message = format [localize LSTRING(hintReturnOwner), name ([_radioId] call FUNC(getExternalRadioUser)), _displayName];
[QGVAR(stopUsingRadioLocal), [_message, _radioId], _owner] call CBA_fnc_targetEvent;
// Give radio back to the owner
[_radioId, "setState", ["radioUsedExternally", [false, objNull]]] call EFUNC(sys_data,dataEvent);
} else {
// Show a hint to the actual owner that the radio was given to another player
private _message = format [localize LSTRING(hintGiveOwner), name ([_radioId] call FUNC(getExternalRadioUser)), _displayName, name _target];
[QGVAR(giveRadioLocal), [_message, _radioId], _owner] call CBA_fnc_targetEvent;
// Give radio to another player
[QGVAR(giveRadioAction), [_radioId, _target], _target] call CBA_fnc_targetEvent;
};