I think sometimes the words "simplistic" and "simple" are used interchangeably.
Hooking SendChatMessage and just changing things is a simplistic implementation. Don't expect that it will work with anything else that does the same thing, and since the chat system is such a major part of the game client, expect any defects in your code to make the game unplayable in some cases.
I just hooked ChatEdit_ParseText rather than SendChatMessage. Problem solved XD
Well that sounds extraordinarily inefficient. ChatEdit_ParseText is run every time you type (or delete) any character while the chat edit box is focused...
Well that sounds extraordinarily inefficient. ChatEdit_ParseText is run every time you type (or delete) any character while the chat edit box is focused...
It only does anything if send == 1. I don't see how a single if statement returning false whenever a key is pressed is any more inefficient than having to check possibly thousands of messages being sent by addons only to not do anything with them.
I use over 200 addons, and none of them use SendChatMessage for anything other than printing reports (Recount, Acheron, etc), and then only when I initiate it. I type far more chat messages than those addons ever send. Your addon though, do what you want. /shrug
It only does anything if send == 1. I don't see how a single if statement returning false whenever a key is pressed is any more inefficient than having to check possibly thousands of messages being sent by addons only to not do anything with them.
The term "inefficient" gets used a lot, with a seemingly broad range of meanings. In this specific case, there likely won't be any performance impact since you're doing a simple integer comparison. However it is still more inefficient than the other solution brought forth here since your code gets executed a heck of a lot more this way.
Did some more digging, and I agree with you. For some reason I was thinking that sendchatmessage and sendaddonmessage were the same functions, and thus thinking that my hooked function would then be firing on all addon communication.
Switched it over to sendchatmessage... not that it really has any noticeable effect and isn't part of a public addon, but I suppose it's the principal of the thing :P
Did some more digging, and I agree with you. For some reason I was thinking that sendchatmessage and sendaddonmessage were the same functions, and thus thinking that my hooked function would then be firing on all addon communication.
Switched it over to sendchatmessage... not that it really has any noticeable effect and isn't part of a public addon, but I suppose it's the principal of the thing :P
Noone actually knows what you are doing btw. All you said is "make replacements".
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
For example, would it be possible to search the outgoing string for say :name: and replace it with different text before it's sent to the server?
It really doesn't get any simpler than hooking a single function.
Those are for incoming messages.
Hooking SendChatMessage and just changing things is a simplistic implementation. Don't expect that it will work with anything else that does the same thing, and since the chat system is such a major part of the game client, expect any defects in your code to make the game unplayable in some cases.
Look before you leap.
Well that sounds extraordinarily inefficient. ChatEdit_ParseText is run every time you type (or delete) any character while the chat edit box is focused...
It only does anything if send == 1. I don't see how a single if statement returning false whenever a key is pressed is any more inefficient than having to check possibly thousands of messages being sent by addons only to not do anything with them.
The term "inefficient" gets used a lot, with a seemingly broad range of meanings. In this specific case, there likely won't be any performance impact since you're doing a simple integer comparison. However it is still more inefficient than the other solution brought forth here since your code gets executed a heck of a lot more this way.
Switched it over to sendchatmessage... not that it really has any noticeable effect and isn't part of a public addon, but I suppose it's the principal of the thing :P
Noone actually knows what you are doing btw. All you said is "make replacements".