mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 13:01:34 +00:00
79 lines
2.5 KiB
Lua
79 lines
2.5 KiB
Lua
ESX = nil
|
|
|
|
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
|
|
|
AddEventHandler('chatMessage', function(playerId, playerName, message)
|
|
if string.sub(message, 1, string.len('/')) ~= '/' then
|
|
CancelEvent()
|
|
|
|
playerName = GetRealPlayerName(playerId)
|
|
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 playerId == 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 playerId == 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)
|
|
|
|
RegisterCommand('msg', function(source, args, user)
|
|
|
|
if GetPlayerName(tonumber(args[1])) then
|
|
local player = tonumber(args[1])
|
|
table.remove(args, 1)
|
|
|
|
TriggerClientEvent('chat:addMessage', player, {args = {"^1MSG de "..GetPlayerName(source).. "[" .. source .. "]: ^7" ..table.concat(args, " ")}, color = {255, 153, 0}})
|
|
TriggerClientEvent('chat:addMessage', source, {args = {"^1MSG enviado a "..GetPlayerName(player).. "[" .. player .. "]: ^7" ..table.concat(args, " ")}, color = {255, 153, 0}})
|
|
|
|
else
|
|
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "ID de jugador incorrecta!")
|
|
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
|