Im using ESX_rpchat and if someone sends /me (or something) and I’m within 20 meters, I see the message. If I’m within about 50 meters, I don’t see the message. If I’m about 200 meters (estimated) I see the message again.
elseif GetDistanceBetweenCoords(sourceCoords.x, sourceCoords.y, sourceCoords.z, targetCoords.x, targetCoords.y, targetCoords.z, true) < 20 then.....
If I’m roughly 200 meters or more away, sourceCoords (sender) has the same coordinates as me. Whats wrong?
CLIENT
RegisterNetEvent('esx_rpchat:sendDo')
AddEventHandler('esx_rpchat:sendDo', function(playerId, title, message, color)
local source = PlayerId()
local target = GetPlayerFromServerId(playerId)
local sourcePed, targetPed = PlayerPedId(), GetPlayerPed(target)
local sourceCoords, targetCoords = GetEntityCoords(sourcePed), GetEntityCoords(targetPed)
if target == source then
TriggerEvent('chat:addMessage', {
template = '<div style="padding: 0.45vw; margin: 0.05vw; background-color: rgba(220, 173, 17, 0.6); border-radius: 10px;"><i class="fas fa-users"></i> {1}(({0}))</div>',
args = { title, message }
})
elseif GetDistanceBetweenCoords(sourceCoords.x, sourceCoords.y, sourceCoords.z, targetCoords.x, targetCoords.y, targetCoords.z, true) < 20 then
TriggerEvent('chat:addMessage', {
template = '<div style="padding: 0.45vw; margin: 0.05vw; background-color: rgba(220, 173, 17, 0.6); border-radius: 10px;"><i class="fas fa-user-street-view"></i> {1}(({0}))</div>',
args = { title, message }
})
end
end)
SERVER
RegisterCommand('do', function(source, args, rawCommand)
if source == 0 then
print('esx_rpchat: you can\'t use this command from rcon!')
return
end
args = table.concat(args, ' ')
local name = GetPlayerName(source)
xPlayer = ESX.GetPlayerFromId(source)
if Config.EnableESXIdentity then name = GetCharacterName(source) end
TriggerClientEvent('esx_rpchat:sendDo', -1, source, xPlayer.getName(), args, { 255, 198, 0 })
end)