Changing the string of a chat message client-sided

I’m trying to create a chat censor, and I want it to be toggleable.
So everything is done on the client’s side.
Buuut I came across a problem when trying to change the text. Unlike PlayerSay, OnPlayerChat returns a boolean so I had to completely overwrite the chat, like so:

[lua]hook.Add( “OnPlayerChat”, “BlahblahWhatever”, function( ply, text, isDead, teamOnly )
–Blah blah blah change text to something else
chat.AddText( /Whatever/ )
return true
end )[/lua]

But this overwrites custom chat stuff made by other addons.
Is there anyway I can change just the text, client-side?

I don’t think so, but you can easily do that with

GM/PlayerSay… I don’t really know why you want to do it clientside

[editline]31st March 2016[/editline]

Also, if it’s toggleable (I assume you mean toggleable clientside) then why even have it? Clients could just disable it whenever they want

Exactly, one might not want to have words censored, whereas some people might want it (Assuming you censor really bad words and not stuff like the F word, I can see a situation where some will want to have it, and some not).

I think I’ll just not let the client receive it at all if it’s such a problem

I’m looking at the OnPlayerChat wiki page and you mentioned how it returns a boolean - apparently this is for ‘Should the message be suppressed?’

So, maybe you could use that? If suppress in this case means display, then you could do that if the convar/toggle is whatever and then manually print the chat line yourself

Maybe you could make a table with the censored words in with another table with the censored word in and make a for loop to check if the message has any words in the first table and use string.gsub to replace them with a random word from the second table?

That’s exactly what he’s doing in the OP, but as he says it overrides some addon stuff

Oh, I thought you meant it censored the local player’s text only, as in they have the choice to censor what they type in rather than censoring what others type, meaning they could choose if others get to see their swears or whatever