Issue with disabling text chat

So I’ve pretty confused on why this won’t work, I’ve asked in scripting chat but still can’t figure it out, so why not come to the forums.

The whole point is, type /tc or /textchat, and It’ll disable text chat.

Client.lua

RegisterNetEvent('SetTextChatEnabled')
AddEventHandler('SetTextChatEnabled', function()
    SetTextChatEnabled(false)
end )

Server.lua

AddEventHandler( 'chatMessage', function( source, n, msg )  

    msg = string.lower( msg )
    if ( msg == "/tc" or msg == "/textchat" ) then 
        TriggerClientEvent( 'SetTextChatEnabled', source )
		CancelEvent()
    end
end )

I’ve tried doing this inside of the actual chat function as well, but that still doesn’t work. Any help is greatly appreciated.

I believe we discussed and solved this on discord. For further reference for people with the similair issue:

The reason why this doesn’t work is because the SetTextChatEnabled(bool) enables/disables the ingame chat (the GTA Online chat) and not the chat resource (the one on the top left).

As of now there is no legitimate way of disabling the chat resource by code, you could add in your own way of disabling the chat resource by hidding the chat element via the NUI system.

No legitimate way? Uhm ?

20 character limit 20

I meant a “out of the box” way of disabling.

@TheStonedTurtle Oh nice PR :smiley:

is there a download for this?

20 character limit 20

I tried that the other day as Vespura directed me and did not work.

There has the be a possible legitimate way to do this as DOJ and HSG have this.

20 character limit 20

hey how can i fix my chat i cant type