Hello! I’ve been looking for help regarding an issue I have. I’ve been attempting to disable chat messages in my RP server, while sending a notification using ESX, the problem is though, even though that works, every time I use a command and it doesn’t successfully execute, I get the esx.notification sent anyway. I’m gonna attach my script, hoping for a fix <3
AddEventHandler('chatMessage', function(source, name, message)
CancelEvent()
TriggerClientEvent('esx:showNotification', source, 'Chat has been disabled. Please use ~r~/ooc')
end)
Not sure if this is exactly what you’re looking for but I went into cl_chat.lua and commented the code around line 20 out to avoid it. They still can type and press enter but unless it’s a valid command it doesn’t go into the chat for everyone to see. We still use /ooc /twt, etc…
--[[
--deprecated, use chat:addMessage
AddEventHandler('chatMessage', function(author, color, text)
local args = { text }
if author ~= "" then
table.insert(args, 1, author)
end
SendNUIMessage({
type = 'ON_MESSAGE',
message = {
color = color,
multiline = true,
args = args
}
})
end)
--]]
I did manage to disable chat with no further issues, but I was wondering if there’s any possible way to trigger an Event ‘esx:showNotification’ to lay out a message saying “please use /ooc”.