I am deploying on my OneSync Infinity server, but I have noticed that proximity does not work properly. All voices are heard, all proximity messages (/ me / do) etc. Is there any chance to fix this?
for the example this is the code of proximity chat.
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', { args = { title, message }, color = color })
elseif GetDistanceBetweenCoords(sourceCoords, targetCoords, true) < 20 then
TriggerEvent('chat:addMessage', { args = { title, message }, color = color })
end
end)
That’s because of the scoping that is present when using Infinity. The client isn’t aware of all active players in the server, only players within their scope. So, you should use the server and compare distance by iterating GetPlayers (if Lua, else see scheduler.lua for example).
I have made this code totally on the server side, but putting the command does nothing
TriggerEvent('es:addCommand', 'me', function(source, args, user)
if source == 0 then
print('esx_rpchat: you can\'t use this command from rcon!')
return
end
local players = ESX.GetPlayers()
if #players == 0 then return end
for i = 1, #players do
args = table.concat(args, ' ')
local name = GetPlayerName(source)
local coords = GetEntityCoords(GetPlayerPed(players[i]))
local coords2 = GetEntityCoords(GetPlayerPed(source))
if Config.EnableESXIdentity then name = GetCharacterName(source) end
print(coords2, coords)
if (coords2 - coords) < 20 then
TriggerClientEvent('chatMessage', -1, '^1me: ' .. args, { 128, 128, 128 })
TriggerServerEvent('discordboaardo:ToDiscord', 'chat', GetPlayerName(id) .. ' [ID: ' .. GetPlayerServerId(id) .. ']', data.message, 'steam', GetPlayerServerId(id), false, true)
--print(('%s: %s'):format(name, args))
end
end
end, false)
yes you can settle the concerns you just have to make sure that it is the server side of your script which checks the distance between the players and sends the result back to the client. we did it for our server and made mumble-voip and 3dme compatible compatible with infinity
I’m doing it but I don’t know why GetEntityCoords (GetPlayerPed (players [i]))
it does not return the location of the other players, it only returns mine. How do I get the location of other players back?