Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions addons/sys_core/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ PREP(replaceGear);
PREP(setPluginSetting);
PREP(setSpeakingLanguage);
PREP(setSpokenLanguages);
PREP(shouldBeMuted);
PREP(showBroadCastHint);
PREP(speaking);
PREP(spectatorOff);
Expand Down
86 changes: 20 additions & 66 deletions addons/sys_core/fnc_muting.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,88 +30,42 @@ DFUNC(mutingPFHLoop) = {
GVAR(fullListTime) = true;
};
private _mutingParams = "";
private _muting = [];
//private _playerIdList = [];

// CHANGE: dynamically get muting distanced based on camera *OR* acre_player position
private _dynamicPos = getPos acre_player;
if (ACRE_IS_SPECTATOR) then {
_dynamicPos = positionCameraToWorld [0, 0, 0];
};
private _mutedClients = [];

{
_x params ["_remoteTs3Id","_remoteUser"];
if (_remoteUser != acre_player) then {
private _muted = 0;
//private _remoteTs3Id = (_remoteUser getVariable QGVAR(ts3id));
//if (!(isNil "_remoteTs3Id")) then {
if !(_remoteTs3Id in ACRE_SPECTATORS_LIST) then {
private _isRemotePlayerAlive = [_remoteUser] call FUNC(getAlive);
if (_isRemotePlayerAlive == 1) then {
//_playerIdList pushBack _remoteTs3Id;

// private _radioListRemote = [_remoteUser] call EFUNC(sys_data,getRemoteRadioList);
// private _radioListLocal = [] call EFUNC(sys_data,getPlayerRadioList);
// private _okRadios = [_radioListLocal, _radioListRemote, true] call EFUNC(sys_modes,checkAvailability);
if (GVAR(enableDistanceMuting) && {_remoteUser distance _dynamicPos > 300}) then {
_muting pushBack _remoteUser;
_muted = 1;
if (_remoteUser in GVAR(speakers)) then {
_muted = 0;
};
};
private _muted = [_remoteUser, _remoteTs3Id, _dynamicPos] call FUNC(shouldBeMuted);

if (GVAR(fullListTime)) then {
_mutingParams = _mutingParams + format ["%1,%2,", _remoteTs3Id, _muted];
} else {
if ((_muted == 0 && {_remoteUser in GVAR(muting)}) || {(_muted == 1 && {!(_remoteUser in GVAR(muting))})}) then {
_mutingParams = _mutingParams + format ["%1,%2,", _remoteTs3Id, _muted];
};
};
};
} else {
_muting pushBack _remoteUser;
};
//};
};
} forEach GVAR(playerList);

if (!ACRE_IS_SPECTATOR || {GVAR(fullListTime)}) then {
private _newSpectators = ACRE_SPECTATORS_LIST - GVAR(oldSpectators);
if (GVAR(fullListTime)) then {
_newSpectators = ACRE_SPECTATORS_LIST;
};
if (_newSpectators isNotEqualTo []) then {
{
if (_x != GVAR(ts3id)) then {
_mutingParams = _mutingParams + format ["%1,1,", _x];
if (GVAR(fullListTime)) then {
_mutingParams = _mutingParams + format ["%1,%2,", _remoteTs3Id, parseNumber _muted];
if (_muted) then {
_mutedClients pushBack _remoteUser;
};
} forEach _newSpectators;
if (!GVAR(fullListTime)) then {
GVAR(oldSpectators) = +ACRE_SPECTATORS_LIST;
continue;
};
};
} else {
if ((str ACRE_IS_SPECTATOR) != (str GVAR(lastSpectate))) then {
if (ACRE_IS_SPECTATOR) then {
{
if (_x != GVAR(ts3id)) then {
_mutingParams = _mutingParams + format ["%1,0,", _x];
};
} forEach ACRE_SPECTATORS_LIST;
private _isCurrentlyMuted = _remoteUser in GVAR(muting);
if (_isCurrentlyMuted && !_muted) then {
_mutingParams = _mutingParams + format ["%1,0,", _remoteTs3Id];
GVAR(muting) deleteAt (GVAR(muting) find _remoteUser);
} else {
if (!_isCurrentlyMuted && _muted) then {
_mutingParams = _mutingParams + format ["%1,1,", _remoteTs3Id];
GVAR(muting) pushBackUnique _remoteUser;
};
};
GVAR(lastSpectate) = ACRE_IS_SPECTATOR;
};
} forEach GVAR(playerList);
if (GVAR(fullListTime)) then {
GVAR(muting) = _mutedClients;
};

if (ACRE_IS_SPECTATOR && {GVAR(fullListTime)}) then {
{
if (_x != GVAR(ts3id)) then {
_mutingParams = _mutingParams + format ["%1,0,", _x];
};
} forEach ACRE_SPECTATORS_LIST;
};

GVAR(muting) = _muting;
if (GVAR(fullListTime)) then {
GVAR(waitFullSend) = diag_tickTime + FULL_SEND_INTERVAL;
GVAR(fullListTime) = false;
Expand Down
28 changes: 28 additions & 0 deletions addons/sys_core/fnc_shouldBeMuted.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "script_component.hpp"
/*
* Author: ACRE2Team
* Check if a remote TS Client Should be muted
*
* Arguments:
* 0: Unit
* 1: Remote TS Id
* 2: Dynamic Position
*
* Return Value:
* Unit Should Be Muted
*
* Example:
* [] call acre_sys_core_fnc_shouldBeMuted
*
* Public: No
*/
params ["_remoteUser", "_remoteTs3Id", "_dynamicPos"];

if (_remoteUser in EGVAR(sys_godmode,speakingGods)) exitWith { false };
if (ACRE_IS_SPECTATOR && {_remoteTs3Id in ACRE_SPECTATORS_LIST}) exitWith { false };
Comment thread
jokoho48 marked this conversation as resolved.
Outdated
if (!ACRE_IS_SPECTATOR && {_remoteTs3Id in ACRE_SPECTATORS_LIST}) exitWith { true };
if !([_remoteUser] call FUNC(getAlive)) exitWith { false };

GVAR(enableDistanceMuting)
&& {_remoteUser distance _dynamicPos > 300}
&& {!(_remoteUser in GVAR(speakers))}