Skip to content
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.

chat_showMissingCommands #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Tianshee
Copy link

Adding chat_showMissingCommands to combat spam from RP players activating their chat command macros.

Adding chat_showMissingCommands to combat spam from RP players activating their chat command macros.
@Tianshee
Copy link
Author

It does not really change anything unless you add set chat_showMissingCommands 0 in your server config file.

@ekralc
Copy link

ekralc commented Dec 25, 2021

I rarely see servers that haven't modified their chat resource for this purpose. So this option would definitely be useful as a standard feature.

Perhaps this could be changed to still allow for hooking of these messages? It might be useful to do this e.g. for logging or to return an 'Invalid command' response, but hooking isn't possible here because the message is never routed.

@Tianshee
Copy link
Author

Tianshee commented Dec 26, 2021

Honestly, I don't know why anyone want to route failed commands that didn't work and wasn't even shown to anyone. Maybe it should be a separate feature chat_logMissingCommands that would just dump them somewhere? Or they should be always routed as chat messages and it should be a client-side option to ignore them? You can still handle _chat:messageEntered and __cfx_internal:commandFallback events directly in some other resource anyway. That's how I do things instead of touching chat resource itself since it says that editing chat is "strongly discouraged".

@ekralc
Copy link

ekralc commented Dec 26, 2021

You can still handle _chat:messageEntered and __cfx_internal:commandFallback events directly in some other resource anyway. That's how I do things instead of touching chat resource itself since it says that editing chat is "strongly discouraged".

There is no need to edit chat or handle internal events externally. This is exactly why hooking was added, it allows other resources to intercept messages before they're sent (or perhaps never sent). There isn't any documentation for it at the moment (although there is a PR to add some citizenfx/fivem-docs#234)

My existing solution using hooks (in a separate resource) is along the lines of:

exports.chat:registerMessageHook(function(source, outMessage, hookRef)
  if outMessage[1] == '/' then
    hookRef.cancel() -- prevent the message from being sent
  end
  
   -- do other stuff e.g. logging
end)

With the current implementation, enabling this convar would prevent me from doing the 'other stuff', but maybe my use case is just very specific.

@Tianshee
Copy link
Author

To be honest, for me chat was a weird scary shit that most people use without looking inside, like browsers or Microsoft Windows. And when I saw that current version of chat is now 87MB, I gave up on even looking into new code to be honest. I just saw that those old events didn't change and used those to move my code from my old customized chat to separate resource that I called "chat_extensions" that is supposed to work with any version of chat, old, new or customized assuming that old events will not change. Now I will try to use it properly. Thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants