mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 12:01:35 +00:00
70 lines
2.1 KiB
Lua
70 lines
2.1 KiB
Lua
ESX = nil
|
|
|
|
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
|
|
|
AddEventHandler('es:invalidCommandHandler', function(source, command_args, user)
|
|
CancelEvent()
|
|
TriggerClientEvent('chat:addMessage', source, {args = {'^1SYSTEM', _U('unknown_command', command_args[1])}})
|
|
end)
|
|
|
|
AddEventHandler('chatMessage', function(playerId, playerName, message)
|
|
if string.sub(message, 1, string.len('/')) ~= '/' then
|
|
CancelEvent()
|
|
|
|
local xPlayer = ESX.GetPlayerFromId(playerId)
|
|
if xPlayer then playerName = xPlayer.getName() end
|
|
TriggerClientEvent('chat:addMessage', -1, {args = {_U('ooc_prefix', playerName), message}, color = {128, 128, 128}})
|
|
end
|
|
end)
|
|
|
|
RegisterCommand('twt', function(playerId, args, rawCommand)
|
|
if playerId == 0 then
|
|
print('esx_rpchat: you can\'t use this command from console!')
|
|
else
|
|
args = table.concat(args, ' ')
|
|
local playerName = GetRealPlayerName(playerId)
|
|
|
|
TriggerClientEvent('chat:addMessage', -1, {args = {_U('twt_prefix', playerName), args}, color = {0, 153, 204}})
|
|
end
|
|
end, false)
|
|
|
|
RegisterCommand('me', function(playerId, args, rawCommand)
|
|
if source == 0 then
|
|
print('esx_rpchat: you can\'t use this command from console!')
|
|
else
|
|
args = table.concat(args, ' ')
|
|
local playerName = GetRealPlayerName(playerId)
|
|
|
|
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('me_prefix', playerName), args, {255, 0, 0})
|
|
end
|
|
end, false)
|
|
|
|
RegisterCommand('do', function(playerId, args, rawCommand)
|
|
if source == 0 then
|
|
print('esx_rpchat: you can\'t use this command from console!')
|
|
else
|
|
args = table.concat(args, ' ')
|
|
local playerName = GetRealPlayerName(playerId)
|
|
|
|
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('do_prefix', playerName), args, {0, 0, 255})
|
|
end
|
|
end, false)
|
|
|
|
function GetRealPlayerName(playerId)
|
|
local xPlayer = ESX.GetPlayerFromId(playerId)
|
|
|
|
if xPlayer then
|
|
if Config.EnableESXIdentity then
|
|
if Config.OnlyFirstname then
|
|
return xPlayer.get('firstName')
|
|
else
|
|
return xPlayer.getName()
|
|
end
|
|
else
|
|
return xPlayer.getName()
|
|
end
|
|
else
|
|
return GetPlayerName(playerId)
|
|
end
|
|
end
|