chat:addMessage displays for police only /911

Ive been struggling to get RegisterCommand /911 to display to the police and source via esx_rpchat
I have tried muiltiple methods and still nothing works lol

RegisterCommand('911', function(source, args, rawCommand)
    local playerName = GetPlayerName(source)
    local msg = rawCommand:sub(5)
    local name = getIdentity(source)
    fal = name.firstname .. " " .. name.lastname

    TriggerClientEvent('chat:addMessage', -1, {
      template = '<div class="chat-message emergency"><div class="chat-message-header">[Dispatch]: [911] | Caller : {0} | Message : {1}</div><div class="chat-message-body"></div></div>',
      args = { fal, msg }
    })        
end, false)

Helpppp

Fixed, If anybody is intrested in how to do it heres our method.

local players = ESX.GetPlayers()
    for k, source in pairs(players) do
        if ESX.GetPlayerFromId(source).job.name == 'police' then
            TriggerClientEvent('chat:addMessage', source, {
                template = '<div class="chat-message emergency"><div class="chat-message-header">[Dispatch]: [911] | Caller : {0} | Message : {1}</div><div class="chat-message-body"></div></div>',
                args = { playerName, msg }
            })
        end
    end
2 Likes

it’s there any chance that u can share it?

TIA

Change the 911 section

1 Like

thiis doent work …