Trying to display a notification to all players

I’m still kind of new to the client and server side of fivem, but lets go. The idea of my script is to send a notification to all members online.

first I test sending a message to everyone on the server with chat: addMenssage and it worked

TriggerClientEvent("chat:addMessage", -1, {color = {255,0,0}, multiline = true, args = {"[System]", "SERVER TEST"}})

but then I tried to do the same thing, creating a notify event on the client, and calling it on the server

Client:

RegisterNetEvent('notificarAll')
AddEventHandler('notificarAll',function(message)
    function notifyAll(msg)
        SetNotificationTextEntry("STRING")

        AddTextComponentString(msg)

        DrawNotification(0, 0, 0, -1) 
    end
    notifyAll(message)   
end)

Server:

TriggerClientEvent("notificarAll", -1, "SERVER TESTE!")

But unfortunately it doesn’t work, does anyone know how to tell me how to solve it? I already tried in many ways

Replace your client event with:

RegisterNetEvent('notificarAll')
AddEventHandler('notificarAll',function(message)

SetNotificationTextEntry('STRING')
AddTextComponentSubstringPlayerName(message)
DrawNotification(false, true)

end)
1 Like

it didn’t work, I can call the notification by the client but the server won’t

Then you probably do something wrong, show the full code from server side.

Example (Put in server.lua ):

RegisterCommand('notify123', function(source, rawCommand)

TriggerClientEvent("notificarAll", -1, "~r~Test message")

end)

Should work if you type /notify123 in chat

1 Like

now with RegisterCommand it worked, thanks xD