forked from SSPU1W/FiveM-No-Join-Leave-Chat-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sv_chat.lua
34 lines (26 loc) · 1021 Bytes
/
sv_chat.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
RegisterServerEvent('chat:init')
RegisterServerEvent('chat:addTemplate')
RegisterServerEvent('chat:addMessage')
RegisterServerEvent('chat:addSuggestion')
RegisterServerEvent('chat:removeSuggestion')
RegisterServerEvent('_chat:messageEntered')
RegisterServerEvent('chat:clear')
RegisterServerEvent('__cfx_internal:commandFallback')
AddEventHandler('_chat:messageEntered', function(author, color, message)
if not message or not author then
return
end
TriggerEvent('chatMessage', source, author, message)
if not WasEventCanceled() then
TriggerClientEvent('chatMessage', -1, author, { 255, 255, 255 }, message)
end
print(author .. ': ' .. message)
end)
AddEventHandler('__cfx_internal:commandFallback', function(command)
local name = GetPlayerName(source)
TriggerEvent('chatMessage', source, name, '/' .. command)
if not WasEventCanceled() then
TriggerClientEvent('chatMessage', -1, name, { 255, 255, 255 }, '/' .. command)
end
CancelEvent()
end)