mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
Cleanup, default messages to ooc, enforce 2 space indent on locale files
This commit is contained in:
+18
-34
@@ -3,18 +3,14 @@ AddEventHandler('es:invalidCommandHandler', function(source, command_args, user)
|
||||
TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', _U('ooc_unknown_command', command_args[1]) } })
|
||||
end)
|
||||
|
||||
RegisterCommand('ooc', function(source, args, rawCommand)
|
||||
if source == 0 then
|
||||
print('esx_rpchat: you can\'t use this command from rcon!')
|
||||
return
|
||||
AddEventHandler('chatMessage', function(source, name, message)
|
||||
if string.sub(message, 1, string.len('/')) ~= '/' then
|
||||
CancelEvent()
|
||||
|
||||
if Config.EnableESXIdentity then name = GetCharacterName(source) end
|
||||
TriggerClientEvent('chat:addMessage', -1, { args = { _U('ooc_prefix', name), message }, color = { 128, 128, 128 } })
|
||||
end
|
||||
|
||||
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)
|
||||
end)
|
||||
|
||||
RegisterCommand('twt', function(source, args, rawCommand)
|
||||
if source == 0 then
|
||||
@@ -22,11 +18,12 @@ RegisterCommand('twt', function(source, args, rawCommand)
|
||||
return
|
||||
end
|
||||
|
||||
rawCommand = string.sub(rawCommand, 4)
|
||||
args = table.concat(args, ' ')
|
||||
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 } })
|
||||
TriggerClientEvent('chat:addMessage', -1, { args = { _U('twt_prefix', name), args }, color = { 0, 153, 204 } })
|
||||
print(('%s: %s'):format(name, args))
|
||||
end, false)
|
||||
|
||||
RegisterCommand('me', function(source, args, rawCommand)
|
||||
@@ -35,11 +32,12 @@ RegisterCommand('me', function(source, args, rawCommand)
|
||||
return
|
||||
end
|
||||
|
||||
rawCommand = string.sub(rawCommand, 3)
|
||||
args = table.concat(args, ' ')
|
||||
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 })
|
||||
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('me_prefix', name), args, { 255, 0, 0 })
|
||||
print(('%s: %s'):format(name, args))
|
||||
end, false)
|
||||
|
||||
RegisterCommand('do', function(source, args, rawCommand)
|
||||
@@ -48,30 +46,16 @@ RegisterCommand('do', function(source, args, rawCommand)
|
||||
return
|
||||
end
|
||||
|
||||
rawCommand = string.sub(rawCommand, 3)
|
||||
args = table.concat(args, ' ')
|
||||
local name = GetPlayerName(source)
|
||||
if Config.EnableESXIdentity then name = GetCharacterName(source) end
|
||||
|
||||
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('do_prefix', name), rawCommand, { 0, 0, 255 })
|
||||
end, false)
|
||||
|
||||
RegisterCommand('news', function(source, args, rawCommand)
|
||||
if source == 0 then
|
||||
print('esx_rpchat: you can\'t use this command from rcon!')
|
||||
return
|
||||
end
|
||||
|
||||
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 } })
|
||||
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('do_prefix', name), args, { 0, 0, 255 })
|
||||
print(('%s: %s'):format(name, args))
|
||||
end, false)
|
||||
|
||||
function GetCharacterName(source)
|
||||
-- fetch identity in sync
|
||||
local result = MySQL.Sync.fetchAll('SELECT firstname, lastname FROM users WHERE identifier = @identifier',
|
||||
{
|
||||
local result = MySQL.Sync.fetchAll('SELECT firstname, lastname FROM users WHERE identifier = @identifier', {
|
||||
['@identifier'] = GetPlayerIdentifiers(source)[1]
|
||||
})
|
||||
|
||||
@@ -79,7 +63,7 @@ function GetCharacterName(source)
|
||||
if Config.OnlyFirstname then
|
||||
return result[1].firstname
|
||||
else
|
||||
return result[1].firstname .. ' ' .. result[1].lastname
|
||||
return ('%s %s'):format(result[1].firstname, result[1].lastname)
|
||||
end
|
||||
else
|
||||
return GetPlayerName(source)
|
||||
|
||||
Reference in New Issue
Block a user