Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Pull Req. To merge Server and Client Main To Add Server Side Ringing #154

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
17 changes: 16 additions & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,19 @@ RegisterNetEvent('qb-phone:server:SaveMetaData', function(MData)
if not Player then return end

Player.Functions.SetMetaData("phone", MData)
end)
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)
Loading