Page MenuHomeFeedback Tracker

Mission event handler request: ChatMessageReceived
Closed, ResolvedPublic

Description

Mission Event: ChatMessageReceived
Description: Fires when a message is received, before adding it to the chat feed. Return true to block a message from being added to the chat feed.
Parameters:

  • index: Number - The channel index the message was sent in (indexes as per currentChannel, -1 for system)
  • sender id: Number - Owner ID of the sender
  • sender name: String - Name of the sender
  • message: String - The message contents

Example:

addMissionEventhandler ["ChatMessageReceived",{
	params ["_index","_senderID","_senderName","_message"];
}];

Parameter Examples:
https://i.imgur.com/kHXr0D6.png

[0,3,"Connor","""my globalChat message"""]
[0,3,"Connor","my global message"]
[1,3,"Connor","my side message"]
[5,3,"Connor","my direct message"]

https://i.imgur.com/ejdqYw0.png

[-1,2,"","BattlEye Client: (Global) Admin: my rcon message"]
[-1,2,"","Player Connor (2) connecting"]
[-1,2,"","Player Connor (2) connected"]
[-1,2,"Connor","Player Connor (2) kicked off: "]
[-1,2,"","Player Connor (2) disconnected"]

Details

Severity
Feature
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10
Category
Feature Request
Additional Information

Context:
The available methods of detecting messages added to the chat feed don't allow detecting every type of message. I am able to detect player-sent messages without any trouble, command messages such as systemChat and groupChat have to go through a function, system connection and kill logs are artificially recreated with other event handlers and I am simply unable to detect battleye/rcon messages and client kick/ban logs.

This event handler would remove the need for such hacky and inconvenient solutions as it would provide a single point where all messages can be detected.

Other:

  • Being able to return true to filter out certain messages isn't entirely necessary, however it would be nice to have.
  • It may also be useful to provide a parameter that specifies the method used to send a message. eg: player chat, command, battleye/rcon, system messages.

Event Timeline

_connor created this task.May 11 2020, 4:19 AM
heyoxe added a subscriber: heyoxe.Jun 6 2020, 7:00 PM
dedmen added a project: Restricted Project.Jun 7 2020, 2:59 PM
dedmen set Ref Ticket to AIII-53004.
dedmen moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.
dedmen added a subscriber: dedmen.EditedJul 7 2020, 6:38 PM

sender id: Number - Owner ID of the sender

Not sure if I can do that, alternative would be netID.

dedmen moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Jul 7 2020, 6:46 PM
dedmen claimed this task.
dedmen changed the task status from New to Assigned.

That should be fine.

Mission Event: HandleChatMessage
Description: Fires when a message is received, before adding it to the chat feed. Return true to block a message from being added to the chat feed. Fires clientside
Parameters:

index: Number - The channel index the message was sent in (indexes as per currentChannel, 0 for system)
sender id: Number - Owner ID of the sender
sender name: String - Name of the sender
message: String - The message contents

Needs to return true or false. true == skip/don't print the message, if you return false or anything non-boolean it will print it as normal.

dev-branch next week

dedmen changed the task status from Assigned to Feedback.Jul 30 2020, 2:28 PM
dedmen moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.

With no event handler added, my messages always say "Der Chat wurde deaktiviert, deine Nachricht wurde nicht gesendet." in the chat feed, even though I'm not typing that. Also it doesn't broadcast the message but that makes sense if it were actually disabled.
With the event handler added and returning nil or false, same result as above.
With the event handler added and returning true, it changes the message to that sentence above and doesn't print anything in chat, so the blocking of messages does work correctly.

systemChat messages and player connect/disconnect/kick/rcon system messages don't seem to fire the event so I assume system messages in general aren't recognized. Perhaps related to where you said "(indexes as per currentChannel, 0 for system)" but system should be -1 because global is 0?

The second element in the event handler arguments array (sender id) isn't the owner id of the sender like the wiki says it is.
[0,9.30096e+008,"Civilian (Connor)","globalChat"]

Thanks for pushing a fix to RC, the game-breaking issues are now solved.

There are still some less significant issues with this event though.

The event does not fire for system messages.
EG: systemChat messages and player connect/disconnect/kick/rcon messages. Everything in the system channel.

The second element of the event parameters is not the owner ID.
In my test cases today, when clientOwner == 4 the ID provided by the event was 2.13571e+009, and on another session with the same clientOwner == 4, the event ID was 1.53229e+009.
The only scenario where I've seen them match is when the player is also the host, so both IDs are 2.

Just tested the latest RC with the new changes. Thanks for the additional arguments.

systemChat, mp chat commands and rcon private/global messages appear to work now, but connect/disconnect/kick/ban/vote kick/vote admin/death and rcon kick/ban messages still dont fire the event.

Is this intentional?

This comment was removed by Dwarden.

Is this intentional?

we will look at it later

I've just noticed this while testing one of my mods so I'll note it here for the record:

Death messages do fire the event, but only for the person who died.
[0,4,"","Connor was killed by Connor (2) (Friendly fire)",<NULL-object>,"","-1",true,false,1,2]

What does forcedDisplay and isPlayerMessage represent exactly? I see them as true and false respectively but cant seem to figure out what makes them switch.

@_connor You will have to experiment to find out, not sure myself

I have found the other message types firing on the server, so the exact issue with all the remaining message types seems to be the event only fires where the message is "local".

i.e.
death messages - fires only on victim
connect/disconnect/kick/ban and rcon kick/ban messages - fires only on server

The event handler should fire on any message getting added to the local chat. Which messages display in local chat but not fire EH?

Death messages are added to the chat feed for all players but the event only fires on the player who died.

16:34:43 [0,4,"","Connor was killed",<NULL-object>,"","-1",true,false,1,2]
16:36:12 [0,5,"","Connor (2) was killed by Connor (Friendly fire)",<NULL-object>,"","-1",true,false,1,2]

These multiplayer messages are added to the chat feed for all players but the event only fires on the server.

16:34:30 [16,2,"","Player Connor connected",<NULL-object>,"","-1",true,false,1,0]
16:36:50 [16,2,"","Player Connor (2) disconnected",<NULL-object>,"","-1",true,false,1,0]

16:43:56 [16,2,"","Player Connor (2) banned",<NULL-object>,"","-1",true,false,1,0]
16:43:28 [16,2,"","Player Connor (2) banned: ",<NULL-object>,"","-1",true,false,1,0]
16:41:52 [16,2,"","Player Connor (2) kicked off: ",<NULL-object>,"","-1",true,false,1,0]
16:42:29 [16,2,"","Player Connor (2) kicked off: Due to how the server is set up you are not allowed to connect for 82 more seconds",<NULL-object>,"","-1",true,false,1,0]

16:39:11 [16,2,"","Player Connor (2) kicked off by BattlEye: Admin Ban",<NULL-object>,"","-1",true,false,1,0]
16:37:40 [16,2,"","Player Connor (2) kicked off by BattlEye: Admin Kick",<NULL-object>,"","-1",true,false,1,0]
16:38:10 [16,2,"","Player Connor (2) kicked off by BattlEye: Due to how the server is set up you are not allowed to connect for 89 more seconds",<NULL-object>,"","-1",true,false,1,0]

16:56:28 [16,2,"","Player Connor is losing connection",<NULL-object>,"","-1",true,false,1,0]
16:51:31 [16,2,"","Files C:\Program Files (x86)\Steam\steamapps\common\Arma 3\_client\@ColorPicker\addons\cau.colorpicker.pbo are not signed by a key accepted by this server. To play on this server, remove listed files or install additional accepted keys.",<NULL-object>,"","-1",true,false,1,0]

This connecting message is added to the chat feed for all players but the event doesn't fire anywhere.

Player Connor connecting

Thanks for investigating, we are going to take closer look before 2.02

Jaffa added a subscriber: Jaffa.Oct 18 2020, 4:05 PM

@_connor Does blocking the death message (by returning true) stop the message appearing in all clients or only in the victim's client?

Only the victim. With all messages blocked on the victim, other players still see the death message. Same with multiplayer messages. If all messages are blocked on the server, players still see multiplayer messages.

dedmen added a comment.Jan 6 2021, 4:39 PM

I hope above stuff fixed for profiling v10, or next dev branch whenever that might be

Everything appears to be fixed on v10. Thanks Dedmen.

BIS_fnc_KK removed BIS_fnc_KK as the assignee of this task.Jan 22 2021, 9:33 AM
BIS_fnc_KK added a subscriber: BIS_fnc_KK.
dedmen closed this task as Resolved.May 19 2021, 2:17 PM
dedmen claimed this task.