mtasa-blue
                                
                                 mtasa-blue copied to clipboard
                                
                                    mtasa-blue copied to clipboard
                            
                            
                            
                        onClientChatMessage colorCoded parameter
Is your feature request related to a problem? Please describe.
I'm trying to create a chat system using this event but the outputChatBox part uses the colorCode parameter all the time. Some of the lines are not intended to be colorCoded (e.g. admin panel messages), instead it would be nice if there's an option to differentiate between colorCoded messages and plain HEX messages.
Describe the solution you'd like
just add this parameter in the event itself, if there's no problem in doing that
Describe alternatives you've considered
string.match with string.gsub would be an obvious choice, but it will ruin anything that intends to be colorCoded or going through every resource and modifying anything that is chat related which would be a pain to do
Additional context
No response
Security Policy
- [X] I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
Have you considered checking if the message contains hex codes and setting the colorCoded argument based on that?
local message = "#0fc0fcHello there!"
local colorCoded = string.match(message, "#%w%w%w%w%w%w") and true or false
outputChatBox(message, 255, 0, 0, colorCoded)
If this doesn't satisfy your requirements, please provide a test resource (or atleast some example code) so we can better understand the issue you're facing.
Have you considered checking if the message contains hex codes and setting the
colorCodedargument based on that?local message = "#0fc0fcHello there!" local colorCoded = string.match(message, "#%w%w%w%w%w%w") and true or false outputChatBox(message, 255, 0, 0, colorCoded)If this doesn't satisfy your requirements, please provide a test resource (or atleast some example code) so we can better understand the issue you're facing.
just a simple example: since the chat-system uses the colorCoded argument from the onClientChatMessage event all the time, try printing these two lines differently (keep in mind that both messages are from two separate resources):
"#FF0000Hello #00FF00World!" -- supposed to be colorcoded
"#FF00FFPlayer1 has been banned by #555555Player2" -- not supposed to be colorcoded, and any adjustments would've been made later
and the event would look like this
-- included the suggested parameter, note that this does not exist yet
addEventHandler("onClientChatMessage", root, function(message, r, g, b, messageType, colorCoded)
      -- before this is the cancelEvent part that is not important
      -- the message could be anything, with or without HEX codes, you'll never know
      local message = (colorCoded and message:gsub("#%x%x%x%x%x%x", "")) or message
      outputChatBox("*** "..message.." ***", root, r, g, b, colorCoded) -- print the formatted chat depending on how outputChatBox was called from the other resource
      -- original message: "I am very awesome"
      -- output: "*** I am very awesome ***"
end)
there is a bit of confusion in why would something like this exist in the first place, and a simple example is hard to give since there's none to give at the moment