-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add chat component * Implement chat restriction setting * Common - Add network synced admin state gvar * Add isAdmin handlers only on clients * Fix translation * Fix admin/zeus prefix not added on remote clients * Update addons/chat/stringtable.xml Co-authored-by: 3Mydlo3 <[email protected]> * Update addons/chat/stringtable.xml Co-authored-by: 3Mydlo3 <[email protected]> * Move chat channels ids to defines --------- Co-authored-by: 3Mydlo3 <[email protected]>
- Loading branch information
Showing
14 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
z\afm\addons\chat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Extended_PreStart_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); | ||
}; | ||
}; | ||
class Extended_PreInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); | ||
}; | ||
}; | ||
class Extended_PostInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit)); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Chat | ||
|
||
Game chat related features. | ||
|
||
### Chat lock | ||
|
||
This components adds an option to block global (system and side) chats, making them visible only to sender and logged in admins and zeuses. | ||
|
||
## Authors | ||
|
||
- [veteran29](https://github.com/veteran29) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PREP(handleChatMessage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "script_component.hpp" | ||
|
||
if (hasInterface) then { | ||
addMissionEventHandler ["HandleChatMessage", { | ||
call FUNC(handleChatMessage); | ||
}]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "script_component.hpp" | ||
ADDON = false; | ||
|
||
PREP_RECOMPILE_START; | ||
#include "XEH_PREP.hpp" | ||
PREP_RECOMPILE_END; | ||
|
||
#include "initSettings.inc.sqf" | ||
|
||
ADDON = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "script_component.hpp" | ||
#include "XEH_PREP.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "script_component.hpp" | ||
|
||
class CfgPatches { | ||
class ADDON { | ||
name = COMPONENT_NAME; | ||
units[] = {}; | ||
weapons[] = {}; | ||
requiredVersion = REQUIRED_VERSION; | ||
requiredAddons[] = { | ||
"afm_common" | ||
}; | ||
author = "ArmaForces"; | ||
authors[] = {"veteran29"}; | ||
VERSION_CONFIG; | ||
}; | ||
}; | ||
|
||
#include "CfgEventHandlers.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: veteran29 | ||
* Handle chat message. | ||
* | ||
* Arguments: | ||
* 0: Channel <NUMBER> | ||
* 1: N/A | ||
* 2: N/A | ||
* 3: Sent text <STRING> | ||
* 4: Person sending the message <OBJECT> | ||
* | ||
* Return Value: | ||
* Should message be blocked <BOOL> | ||
* | ||
* Example: | ||
* call afm_chat_fnc_handleChatMessage | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params [["_channel", -1], "", ["_from", ""], ["_text", ""], ["_sender", objNull]]; | ||
if (_text == "") exitWith {false}; | ||
|
||
if (GVAR(allowGlobalChat) || {!(_channel in RESTRICTED_CHANNELS)}) exitWith {false}; | ||
|
||
if (_sender getVariable [QEGVAR(common,isAdmin), false]) exitWith { | ||
[format ["(ADMIN) %1", _from], _text] | ||
}; | ||
|
||
if (!isNull getAssignedCuratorLogic _sender) exitWith { | ||
[format ["(ZEUS) %1", _from], _text] | ||
}; | ||
|
||
if (_sender isEqualTo player) exitWith { | ||
systemChat LLSTRING(AllowGlobalChat_Warning); | ||
playSound "3DEN_notificationWarning"; | ||
|
||
false // return, player always sees his own message | ||
}; | ||
|
||
isNull getAssignedCuratorLogic player // show all messages to zeus | ||
&& !(player getVariable [QEGVAR(common,isAdmin), false]) // show all messages to admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "..\script_component.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
[ | ||
QGVAR(allowGlobalChat), | ||
"CHECKBOX", | ||
[LSTRING(AllowGlobalChat), LSTRING(AllowGlobalChat_Description)], | ||
LSTRING(DisplayName), | ||
true, | ||
1 | ||
] call CBA_fnc_addSetting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#define COMPONENT chat | ||
#include "\z\afm\addons\main\script_mod.hpp" | ||
|
||
// #define DEBUG_MODE_FULL | ||
// #define DISABLE_COMPILE_CACHE | ||
|
||
#ifdef DEBUG_ENABLED_CHAT | ||
#define DEBUG_MODE_FULL | ||
#endif | ||
#ifdef DEBUG_SETTINGS_CHAT | ||
#define DEBUG_SETTINGS DEBUG_SETTINGS_CHAT | ||
#endif | ||
|
||
#include "\z\afm\addons\main\script_macros.hpp" | ||
|
||
#define CHAT_CHANNEL_GLOBAL 0 | ||
#define CHAT_CHANNEL_SIDE 1 | ||
#define RESTRICTED_CHANNELS [CHAT_CHANNEL_GLOBAL, CHAT_CHANNEL_SIDE] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project name="AFM"> | ||
<Package name="Chat"> | ||
<Key ID="STR_AFM_Chat_DisplayName"> | ||
<English>ArmaForces - Chat</English> | ||
<Polish>ArmaForces - Czat</Polish> | ||
</Key> | ||
<Key ID="STR_AFM_Chat_AllowGlobalChat"> | ||
<English>Allow global/side chat</English> | ||
<Polish>Zezwól na czat globalny/strony</Polish> | ||
</Key> | ||
<Key ID="STR_AFM_Chat_AllowGlobalChat_Description"> | ||
<English>Should players be allowed to chat on global and their side chat. If disabled chat messages from these channels will only be visible to admins and zeus players.</English> | ||
<Polish>Czy gracze mają mieć możliwość pisania na czacie globalnym i czacie swojej strony. Jeżeli wyłączone to wiadomości z tych kanałów będą widoczne tylko dla administratorów i zeusów.</Polish> | ||
</Key> | ||
<Key ID="STR_AFM_Chat_AllowGlobalChat_Warning"> | ||
<English>Global and side chat is disabled, your message is visible only to administrators and zeuses!</English> | ||
<Polish>Czat globalny i strony jest wyłączony, twoja wiadomość jest widoczna tylko dla administratorów i zeusów!</Polish> | ||
</Key> | ||
</Package> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
#include "script_component.hpp" | ||
#include "script_component.hpp" | ||
|
||
if (hasInterface) then { | ||
["login", { | ||
[{IS_ADMIN}, { | ||
player setVariable [QGVAR(isAdmin), true, true]; | ||
}, nil, 5] call CBA_fnc_waitUntilAndExecute; | ||
}, "all"] call CBA_fnc_registerChatCommand; | ||
|
||
["logout", { | ||
if (player getVariable [QGVAR(isAdmin), false]) then { | ||
player setVariable [QGVAR(isAdmin), false, true]; | ||
}; | ||
}, "all"] call CBA_fnc_registerChatCommand; | ||
|
||
["unit", { | ||
params ["_newPlayer", "_oldPlayer"]; | ||
|
||
if (IS_ADMIN) then { | ||
_newPlayer setVariable [QGVAR(isAdmin), true, true]; | ||
}; | ||
|
||
if (_oldPlayer getVariable [QGVAR(isAdmin), false]) then { | ||
_oldPlayer setVariable [QGVAR(isAdmin), false, true]; | ||
}; | ||
}, true] call CBA_fnc_addPlayerEventHandler; | ||
}; |