Files
MissionTemplate/framework/client/functions/fn_bindEventHandlers.sqf
hizumi 2bd8a16079 Update fn_bindEventHandlers.sqf
correct logic for handling chat messages based on allowed channel cba settings
2025-05-25 22:48:53 -05:00

44 lines
1.7 KiB
Plaintext

#include "..\script_component.hpp"
if ( !hasInterface ) exitWith {};
[
{
params ["_unit", "_object", "_cost"];
private _return = (count nearestObjects [_unit, ["B_APC_Tracked_01_CRV_F", "rhsusf_M1239_M2_Deploy_socom_d", "rhsusf_stryker_m1132_m2_wd", "rhsusf_m113_usarmy_supply", "rhsusf_M1078A1P2_B_WD_CP_fmtv_usarmy", "B_Slingload_01_Cargo_F"], 120]) > 0;
_return
}
] call ace_fortify_fnc_addDeployHandler;
addMissionEventHandler ["HandleChatMessage",
{
params ["_channel", "_owner", "_from", "_text", "_person", "_name", "_strID", "_forcedDisplay", "_isPlayerMessage", "_sentenceType", "_chatMessageType"];
if ( ( admin _owner ) != 0 ) exitWith { false };
if ( !isNull ( getAssignedCuratorLogic _person ) ) exitWith { false };
if ( (missionNamespace getVariable ["milsim_globalChat", false] ) && ( _channel == 0 ) ) exitWith{ false };
if ( (missionNamespace getVariable ["milsim_sideChat", false] ) && ( _channel == 1 ) ) exitWith{ false };
if ( (missionNamespace getVariable ["milsim_commandChat", false] && ( _channel == 2 ) ) ) exitWith{ false };
if ( (missionNamespace getVariable ["milsim_groupChat", false] ) && ( _channel == 3 ) ) exitWith{ false };
if ( (missionNamespace getVariable ["milsim_vehicleChat", false] && ( _channel == 4 ) ) ) exitWith{ false };
if ( (missionNamespace getVariable ["milsim_directChat", false] ) && ( _channel == 5 ) ) exitWith{ false };
true;
}
];
["ace_arsenal_displayClosed", {
[player] remoteExec [QEFUNC(common,checkPlayerInventory), 2];
}] call CBA_fnc_addEventHandler;
[missionNamespace, "arsenalClosed", {
[player] remoteExec [QEFUNC(common,checkPlayerInventory), 2];
}] call BIS_fnc_addScriptedEventHandler;
diag_log text "[MILSIM] (client) event handlers bound";
nil;