Please, you have to use the function that does not display the chat as if it did not exist for them:

RegisterNetEvent ( ‘localsenddw’)
AddEventHandler (‘localsenddw’, function (id, message, color)
local source = PlayerId ()
local target = GetPlayerFromServerId (id)
playerName = GetPlayerName (target)

if PlayerData.job ~ = nil and PlayerData.job.name == ‘police’ or PlayerData.job.name == ‘offpolice’ or PlayerData.job.name == ‘ambulance’ or PlayerData.job.name == 'offambulance 'then

else

TriggerEvent (‘chat: addMessage’, {
args = {playerName, message}
})
end
end)

You have to add this option to server / main.lua:
RegisterCommand (‘dw’, function (source, args, message)
local playerName = GetPlayerName (source)
local player = source
local message = message: sub (3)
local _source = source
local xPlayer = ESX.GetPlayerFromId (_source)
if xPlayer ~ = nil and xPlayer.job ~ = nil and xPlayer.job.name == ‘police’ or xPlayer.job.name == ‘offpolice’ or xPlayer.job.name == ‘ambulance’ or xPlayer.job. name == ‘offambulance’ then
TriggerClientEvent (‘esx: showNotification’, source, ‘~ r ~ You are a law enforcement service, darkweb is not for you!’)
else
TriggerClientEvent (‘localsenddw’, -1, player, message, {255, 0, 134})
end
end, false)

I sent in all my function that works for me.