diff --git a/client/main.lua b/client/main.lua index 820da39..5b38138 100644 --- a/client/main.lua +++ b/client/main.lua @@ -738,7 +738,7 @@ RegisterNetEvent('qb-phone:client:GetCalled', function(CallerNumber, CallId, Ano if RepeatCount + 1 ~= Config.CallRepeats + 1 then if PhoneData.CallData.InCall then RepeatCount = RepeatCount + 1 - TriggerServerEvent("InteractSound_SV:PlayOnSource", "ringing", CallVolume) + TriggerServerEvent("qb-phone:server:BroadcastRing", GetEntityCoords(PlayerPedId()), CallVolume) if not PhoneData.isOpen then SendNUIMessage({ diff --git a/server/main.lua b/server/main.lua index 2d54754..3e4755e 100644 --- a/server/main.lua +++ b/server/main.lua @@ -276,4 +276,19 @@ RegisterNetEvent('qb-phone:server:SaveMetaData', function(MData) if not Player then return end Player.Functions.SetMetaData("phone", MData) -end) \ No newline at end of file +end) + +RegisterServerEvent('qb-phone:server:BroadcastRing') +AddEventHandler('qb-phone:server:BroadcastRing', function(coords, maxVolume) + local src = source + local players = QBCore.Functions.GetPlayers() + local maxDistance = 20.0 + + for _, player in ipairs(players) do + local dist = #(GetEntityCoords(GetPlayerPed(player)) - vector3(coords.x, coords.y, coords.z)) + if dist <= maxDistance then + local volume = maxVolume * ((maxDistance - dist) / maxDistance) + TriggerClientEvent("InteractSound_CL:PlayOnOne", player, "ringing", volume) + end + end +end)