mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 14:01:35 +00:00
58 lines
2.0 KiB
Lua
58 lines
2.0 KiB
Lua
AddEventHandler('chatMessage', function(source, author, message)
|
|
|
|
if string.sub(message, 1, 1) == "/" then
|
|
CancelEvent()
|
|
TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', _U('ooc_unknown_command', message) } })
|
|
end
|
|
|
|
end)
|
|
|
|
RegisterCommand('ooc', function(source, args, rawCommand)
|
|
rawCommand = string.sub(rawCommand, 4)
|
|
local name = GetPlayerName(source)
|
|
if Config.EnableESXIdentity then name = GetCharacterName(source) end
|
|
|
|
TriggerClientEvent('chat:addMessage', -1, { args = { _U('ooc_prefix', name), rawCommand }, color = { 128, 128, 128 } })
|
|
end, false)
|
|
|
|
RegisterCommand('twt', function(source, args, rawCommand)
|
|
rawCommand = string.sub(rawCommand, 4)
|
|
local name = GetPlayerName(source)
|
|
if Config.EnableESXIdentity then name = GetCharacterName(source) end
|
|
|
|
TriggerClientEvent('chat:addMessage', -1, { args = { _U('twt_prefix', name), rawCommand }, color = { 0, 153, 204 } })
|
|
end, false)
|
|
|
|
RegisterCommand('me', function(source, args, rawCommand)
|
|
rawCommand = string.sub(rawCommand, 3)
|
|
local name = GetPlayerName(source)
|
|
if Config.EnableESXIdentity then name = GetCharacterName(source) end
|
|
|
|
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('me_prefix', name), rawCommand, { 255, 0, 0 })
|
|
end, false)
|
|
|
|
RegisterCommand('news', function(source, args, rawCommand)
|
|
rawCommand = string.sub(rawCommand, 5)
|
|
local name = GetPlayerName(source)
|
|
if Config.EnableESXIdentity then name = GetCharacterName(source) end
|
|
|
|
TriggerClientEvent('chat:addMessage', -1, { args = { _U('news_prefix', name), rawCommand }, color = { 249, 166, 0 } })
|
|
end, false)
|
|
|
|
function GetCharacterName(source)
|
|
-- fetch identity in sync
|
|
local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
|
|
{
|
|
['@identifier'] = GetPlayerIdentifiers(source)[1]
|
|
})
|
|
|
|
if result[1] ~= nil and result[1].firstname ~= nil and result[1].lastname ~= nil then
|
|
if Config.OnlyFirstname then
|
|
return result[1].firstname
|
|
else
|
|
return result[1].firstname .. ' ' .. result[1].lastname
|
|
end
|
|
else
|
|
return GetPlayerName(source)
|
|
end
|
|
end |