Onesync infinity issue with proximity

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)
3 Likes

Check if target doesn’t equal -1 because target might return -1 if the player is not nearby.

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)
1 Like

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

1 Like

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?

GetPlayers () only returns my id, and not that of all
players. Would you know why?

for _, playerId in ipairs(GetPlayers()) do
		local coordena = GetEntityCoords(GetPlayerPed(playerId))
		print(playerId)
end

image

Seems this was resolved on Discord. Looked as though you were redefining GetPlayers or so.

Yes, I already managed to fix it. Now I am wondering how to make proximity work with Mumble-Voip

1 Like

Does anyone know how it could be solved?

1 Like

how to fix the problem, /me / do, pass me the same

1 Like