Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update globalSay and globalSay3D to use CBA events #1722

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions addons/network/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ class Extended_PreInit_EventHandlers {
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit));
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};
2 changes: 1 addition & 1 deletion addons/network/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class CfgFunctions {
class Network {
PATHTO_FNC(globalExecute);
PATHTO_FNC(globalSay);
PATHTO_FNC(globalSay3d);
PATHTO_FNC(globalSay3D);
PATHTO_FNC(publicVariable);
PATHTO_FNC(setVarNet);
};
Expand Down
18 changes: 18 additions & 0 deletions addons/network/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "script_component.hpp"

if (hasInterface) then {
[QGVAR(say3D), {
params ["_object", "_params", "_attach"];

// Attaching is mainly meant for vehicles in motion
private _source = _object say3D _params;
if (_attach) then {
_source attachTo [_object];
};
}] call CBA_fnc_addEventHandler;

[QGVAR(say), {
params ["_object", "_params"];
_object say _params;
}] call CBA_fnc_addEventHandler;
};
6 changes: 2 additions & 4 deletions addons/network/fnc_globalSay.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Function: CBA_fnc_globalSay
Description:
Says sound on all clients.

DEPRECATED. Use <remoteExec at https://community.bistudio.com/wiki/remoteExec> ["say"] instead.

Parameters:
_objects - Object or array of objects that perform Say <OBJECT, ARRAY>
_params - [sound, maxTitlesDistance,speed] or "sound" <ARRAY, STRING>
Expand All @@ -20,7 +18,7 @@ Example:
(end)

Author:
Sickboy, commy2
Sickboy, commy2, DartRuffian
---------------------------------------------------------------------------- */

params [["_objects", [], [[], objNull]], ["_params", "", ["", []]]];
Expand All @@ -30,7 +28,7 @@ if (_objects isEqualType objNull) then {
};

{
[_x, _params] remoteExecCall ["say"];
[QGVAR(say), [_x, _params]] call CBA_fnc_globalEvent;
} forEach _objects;

nil
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_globalSay3d
Function: CBA_fnc_globalSay3D

Description:
Says sound on all clients in 3D.

DEPRECATED. Use <remoteExec at https://community.bistudio.com/wiki/remoteExec> ["say3D"] instead.

Parameters:
_objects - Object or array of objects that perform Say <OBJECT, ARRAY>
_params - [sound, maxTitlesDistance,speed] or "sound" <STRING, ARRAY>
_range - Maximum distance from camera to execute command (optional) <NUMBER>
_attach - Attach created sound to _object (optional, default: false) <BOOL>

Returns:
Nothing

Example:
(begin example)
[player, "Alarm", 500] call CBA_fnc_globalSay3d;
[player, "Alarm", 500] call CBA_fnc_globalSay3D;
(end)

Author:
Sickboy, commy2
Sickboy, commy2, DartRuffian
---------------------------------------------------------------------------- */

params [["_objects", [], [[], objNull]], ["_params", "", ["", []]], ["_distance", nil, [0]]];
params [["_objects", [], [[], objNull]], ["_params", "", ["", []]], ["_distance", nil, [0]], ["_attach", false, [false]]];

if (_objects isEqualType objNull) then {
_objects = [_objects];
Expand All @@ -35,7 +34,7 @@ if (!isNil "_distance") then {
};

{
[_x, _params] remoteExecCall ["say3D"];
[QGVAR(say3D), [_x, _params, _attach]] call CBA_fnc_globalEvent;
} forEach _objects;

nil
Loading