diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index b766dd5..9f5ab4b 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -44,6 +44,7 @@ if (isServer) then { [QGVAR(createZeus), {call FUNC(createZeus)}] call CBA_fnc_addEventHandler; missionNamespace setVariable [QGVAR(allowChatMessages), true, true]; + missionNamespace setVariable [QGVAR(chatSlowMode), 0, true]; }; if (isDedicated) then { diff --git a/addons/common/XEH_postInitClient.sqf b/addons/common/XEH_postInitClient.sqf index c6adb28..9636d77 100644 --- a/addons/common/XEH_postInitClient.sqf +++ b/addons/common/XEH_postInitClient.sqf @@ -4,6 +4,8 @@ if (!hasInterface) exitWith {}; +GVAR(allowNextMessageTime) = -1; + [missionNamespace, "arsenalOpened", { disableSerialization; params [["_display", displayNull]]; diff --git a/addons/common/commands_admins.inc.sqf b/addons/common/commands_admins.inc.sqf index 405384f..e57a03b 100644 --- a/addons/common/commands_admins.inc.sqf +++ b/addons/common/commands_admins.inc.sqf @@ -89,3 +89,27 @@ [QGVAR(chatMessage), [profileName, format ["Side/Global chat has been %1!", ["unlocked", "locked"] select _disable], "", "", true]] call CBA_fnc_globalEvent; }, "Disable/enable all player chat messages in global and side chat. 0 enable weapons, 1 disable weapons. <#fp.chatlock 0/1>"] call FUNC(registerChatCommand); } forEach ["cl", "chatlock"]; + +{ + [_x, { + params [["_str", ""]]; + if (_str isEqualTo "") exitWith { + systemChat "You need to provide some number in seconds..."; + }; + private _number = parseNumber _str; + if (isNil "_number") exitWith { + systemChat format ["'%1' is not a valid number, chief!", _str]; + playSound "3DEN_notificationWarning"; + }; + + _number = (round _number) max 0; + missionNamespace setVariable [QGVAR(chatSlowMode), _number, true]; + missionNamespace setVariable [QGVAR(allowNextMessageTime), -1, true]; + + if (_number > 0) then { + [QGVAR(chatMessage), [profileName, format ["Chat has been put into slow mode! Currently %1 seconds", _number], "", "", true]] call CBA_fnc_globalEvent; + } else { + [QGVAR(chatMessage), [profileName, "Chat slow mode has been disabled!", "", "", true]] call CBA_fnc_globalEvent; + }; + }, "Puts side/global chat into slow mode. Any number > 0 will enable slow mode. Number is in seconds. Setting the number to 0 will disable slow mode. <#fp.slowmode 0/1>"] call FUNC(registerChatCommand); +} forEach ["sm", "slowmode"]; diff --git a/addons/common/functions/fnc_handleChatMessage.sqf b/addons/common/functions/fnc_handleChatMessage.sqf index 7f9c72f..0eca0ab 100644 --- a/addons/common/functions/fnc_handleChatMessage.sqf +++ b/addons/common/functions/fnc_handleChatMessage.sqf @@ -1,11 +1,32 @@ #include "script_component.hpp" params [["_channel", -1], "", "", "", ["_person", objNull]]; -if (GVAR(allowChatMessages) || {!(_channel in [0,1])}) exitWith {false}; +// Allow admins to always send messages +// Allow sending in vehicle, group, direct, command channels +if (!(_channel in [0, 1]) || isNull _person || {call FUNC(isAdmin)}) exitWith {false}; -if (_person isEqualTo ace_player) then { - systemChat "Messages into global and side chat have been locked! Use whispers if you need to contact zeus or an admin!"; - playSound "3DEN_notificationWarning"; +private _ret = false; + +if !(GVAR(allowChatMessages)) then { + if (_person isEqualTo ace_player) then { + systemChat "Messages into global and side chat have been locked! Use whispers if you need to contact zeus or an admin!"; + playSound "3DEN_notificationWarning"; + _ret = true; + }; +}; + +if (!_ret && GVAR(chatSlowMode) > 0) then { + if (GVAR(allowNextMessageTime) > time) then { + systemChat format ["Chat is in slow mode! You can send your next message in %1 seconds!", round (GVAR(allowNextMessageTime) - time)]; + playSound "3DEN_notificationWarning"; + _ret = true; + } else { + GVAR(allowNextMessageTime) = time + GVAR(chatSlowMode); + // make sure this text appear below your message and not above it + [{ + systemChat format ["You can send your next message in %1 seconds!", GVAR(chatSlowMode)]; + }] call CBA_fnc_execNextFrame; + }; }; -true +_ret