1
0
mirror of https://github.com/citizenfx/cfx-server-data.git synced 2025-01-10 15:43:00 +08:00
cfx-server-data/resources/[system]/chat/chat_server.lua
2016-12-15 13:40:07 +01:00

51 lines
1.5 KiB
Lua

RegisterServerEvent('chatCommandEntered')
RegisterServerEvent('chatMessageEntered')
AddEventHandler('chatMessageEntered', function(name, color, message)
if not name or not color or not message or #color ~= 3 then
return
end
TriggerEvent('chatMessage', source, name, message)
if not WasEventCanceled() then
TriggerClientEvent('chatMessage', -1, name, color, message)
end
print(name .. ': ' .. message)
end)
-- player join messages
AddEventHandler('playerActivated', function()
TriggerClientEvent('chatMessage', -1, '', { 0, 0, 0 }, '^2* ' .. GetPlayerName(source) .. ' joined.')
end)
AddEventHandler('playerDropped', function(reason)
TriggerClientEvent('chatMessage', -1, '', { 0, 0, 0 }, '^2* ' .. GetPlayerName(source) ..' left (' .. reason .. ')')
end)
-- say command handler
AddEventHandler('rconCommand', function(commandName, args)
if commandName == "say" then
local msg = table.concat(args, ' ')
TriggerClientEvent('chatMessage', -1, 'console', { 0, 0x99, 255 }, msg)
RconPrint('console: ' .. msg .. "\n")
CancelEvent()
end
end)
-- tell command handler
AddEventHandler('rconCommand', function(commandName, args)
if commandName == "tell" then
local target = table.remove(args, 1)
local msg = table.concat(args, ' ')
TriggerClientEvent('chatMessage', tonumber(target), 'console', { 0, 0x99, 255 }, msg)
RconPrint('console: ' .. msg .. "\n")
CancelEvent()
end
end)