RegisterServerEvent('gcPhone:acceptCall')
AddEventHandler('gcPhone:acceptCall', function(infoCall, rtcAnswer)
local id = infoCall.id
if AppelsEnCours[id] ~= nil then
if PhoneFixeInfo[id] ~= nil then
onAcceptFixePhone(source, infoCall, rtcAnswer)
return
end
AppelsEnCours[id].receiver_src = infoCall.receiver_src or AppelsEnCours[id].receiver_src
if AppelsEnCours[id].transmitter_src ~= nil and AppelsEnCours[id].receiver_src ~= nil then
AppelsEnCours[id].is_accepts = true
AppelsEnCours[id].rtcAnswer = rtcAnswer
TriggerClientEvent('gcPhone:acceptCall', AppelsEnCours[id].transmitter_src, AppelsEnCours[id], true)
SetTimeout(1000, function()
if AppelsEnCours[id].receiver_src ~= nil and AppelsEnCours[id] ~= nil then
TriggerClientEvent('gcPhone:acceptCall', AppelsEnCours[id].receiver_src, AppelsEnCours[id], false)
end
end)
TriggerClientEvent("gcPhone:stop-call-sound", -1, AppelsEnCours[id].receiver_src)
saveAppels(AppelsEnCours[id])
exports['saltychat']:EstablishCall(AppelsEnCours[id].receiver_src, AppelsEnCours[id].transmitter_src)
exports['saltychat']:EstablishCall(AppelsEnCours[id].transmitter_src, AppelsEnCours[id].receiver_src)
end
end
end)
RegisterServerEvent('gcPhone:rejectCall')
AddEventHandler('gcPhone:rejectCall', function (infoCall)
local id = infoCall.id
if AppelsEnCours[id] ~= nil then
if PhoneFixeInfo[id] ~= nil then
onRejectFixePhone(source, infoCall)
return
end
if AppelsEnCours[id].transmitter_src ~= nil then
TriggerClientEvent('gcPhone:rejectCall', AppelsEnCours[id].transmitter_src)
exports['saltychat']:EndCall(AppelsEnCours[id].receiver_src, AppelsEnCours[id].transmitter_src)
exports['saltychat']:EndCall(AppelsEnCours[id].transmitter_src, AppelsEnCours[id].receiver_src)
end
if AppelsEnCours[id].receiver_src ~= nil then
TriggerClientEvent('gcPhone:rejectCall', AppelsEnCours[id].receiver_src)
exports['saltychat']:EndCall(AppelsEnCours[id].receiver_src, AppelsEnCours[id].transmitter_src)
exports['saltychat']:EndCall(AppelsEnCours[id].transmitter_src, AppelsEnCours[id].receiver_src)
end
if AppelsEnCours[id].is_accepts == false then
saveAppels(AppelsEnCours[id])
end
TriggerClientEvent("gcPhone:stop-call-sound", -1, AppelsEnCours[id].receiver_src)
TriggerEvent('gcPhone:removeCall', AppelsEnCours)
AppelsEnCours[id] = nil
end
end)