1
0
mirror of https://github.com/citizenfx/cfx-server-data.git synced 2025-01-25 19:42:51 +08:00
cfx-server-data/resources/[system]/chat/sv_chat.lua

47 lines
1.6 KiB
Lua
Raw Normal View History

2017-05-21 22:52:55 +08:00
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')
2017-05-18 01:22:20 +08:00
2017-05-21 22:52:55 +08:00
AddEventHandler('_chat:messageEntered', function(author, color, message)
2017-05-18 01:22:20 +08:00
if not message or not author then
return
end
TriggerEvent('chatMessage', source, author, message)
if not WasEventCanceled() then
2017-05-21 22:52:55 +08:00
TriggerClientEvent('chatMessage', -1, author, { 255, 255, 255 }, message)
2017-05-18 01:22:20 +08:00
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)
2017-05-18 01:22:20 +08:00
-- player join messages
2017-07-16 04:33:05 +08:00
AddEventHandler('playerConnecting', function()
2017-05-21 22:52:55 +08:00
TriggerClientEvent('chatMessage', -1, '', { 255, 255, 255 }, '^2* ' .. GetPlayerName(source) .. ' joined.')
2017-05-18 01:22:20 +08:00
end)
AddEventHandler('playerDropped', function(reason)
2017-05-21 22:52:55 +08:00
TriggerClientEvent('chatMessage', -1, '', { 255, 255, 255 }, '^2* ' .. GetPlayerName(source) ..' left (' .. reason .. ')')
2017-05-18 01:22:20 +08:00
end)
RegisterCommand('say', function(source, args, rawCommand)
TriggerClientEvent('chatMessage', -1, (source == 0) and 'console' or GetPlayerName(source), { 255, 255, 255 }, rawCommand:sub(5))
end)