mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 18:28:52 +00:00
@@ -109,6 +109,21 @@ AddEventHandler('esx_phone:addContact', function(name, phoneNumber)
|
||||
})
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_phone:removeContact')
|
||||
AddEventHandler('esx_phone:removeContact', function(name, phoneNumber)
|
||||
|
||||
for key, value in pairs(PhoneData.contacts) do
|
||||
if value.name == name and value.number == phoneNumber then
|
||||
table.remove(PhoneData.contacts,key)
|
||||
end
|
||||
end
|
||||
-- CALL HERE RELOADCONTACT
|
||||
SendNUIMessage({
|
||||
contactRemoved = true,
|
||||
phoneData = PhoneData
|
||||
})
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_phone:addSpecialContact')
|
||||
AddEventHandler('esx_phone:addSpecialContact', function(name, phoneNumber, base64Icon)
|
||||
|
||||
@@ -142,6 +157,16 @@ RegisterNUICallback('add_contact', function(data, cb)
|
||||
|
||||
end)
|
||||
|
||||
RegisterNUICallback('remove_contact', function(data, cb)
|
||||
|
||||
local phoneNumber = tonumber(data.phoneNumber)
|
||||
local contactName = tostring(data.contactName)
|
||||
|
||||
if phoneNumber then
|
||||
TriggerServerEvent('esx_phone:removePlayerContact', phoneNumber, contactName)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_phone:onMessage')
|
||||
AddEventHandler('esx_phone:onMessage', function(phoneNumber, message, position, anon, job, dispatchRequestId)
|
||||
|
||||
+1
-1
@@ -305,7 +305,7 @@ html, body {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.actions .new-msg:hover, .actions .gps:hover, .actions .ok-btn:hover {
|
||||
.actions .new-msg:hover, .actions .gps:hover, .actions .ok-btn:hover, .actions .del-contact:hover {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
|
||||
+18
-1
@@ -7,7 +7,10 @@
|
||||
'<span class="sender">{{sender}}</span><br/><span class="phone-number">#{{phoneNumber}}</span>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="actions"><span class="new-msg newMsg-btn" data-contact-number="{{phoneNumberData}}" data-contact-name="{{senderData}}"></span></div>' +
|
||||
'<div class="actions">' +
|
||||
'<span class="del-contact" data-contact-number="{{phoneNumberData}}" data-contact-name="{{senderData}}">X</span>' +
|
||||
'<span class="new-msg newMsg-btn" data-contact-number="{{phoneNumberData}}" data-contact-name="{{senderData}}"></span>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
;
|
||||
|
||||
@@ -119,6 +122,16 @@
|
||||
}
|
||||
|
||||
$('#phone #repertoire .repertoire-list').html(contactHTML);
|
||||
|
||||
$('.contact .del-contact').click(function() {
|
||||
let name = $(this).attr('data-contact-name');
|
||||
let phoneNumber = $(this).attr('data-contact-number');
|
||||
|
||||
$.post('http://esx_phone/remove_contact', JSON.stringify({
|
||||
contactName: name,
|
||||
phoneNumber: phoneNumber
|
||||
}))
|
||||
});
|
||||
|
||||
$('.contact.online .new-msg').click(function() {
|
||||
showNewMessage($(this).attr('data-contact-number'), $(this).attr('data-contact-name'));
|
||||
@@ -451,6 +464,10 @@
|
||||
hideAddContact();
|
||||
}
|
||||
|
||||
if(data.contactRemoved === true){
|
||||
reloadPhone(data.phoneData);
|
||||
}
|
||||
|
||||
if(data.addSpecialContact === true){
|
||||
addSpecialContact(data.name, data.number, data.base64Icon);
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ Locales['br'] = {
|
||||
['cannot_add_self'] = 'Você não pode se adicionar',
|
||||
['number_in_contacts'] = 'Este número já está na sua lista de contatos',
|
||||
['contact_added'] = 'Contato adicionado',
|
||||
['contact_removed'] = 'the contact has been removed!',
|
||||
['number_not_assigned'] = 'Este número não foi atribuído...',
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ Locales['de'] = {
|
||||
['cannot_add_self'] = 'du kannst dich nicht selbst hinzufügen',
|
||||
['number_in_contacts'] = 'diese Nummer ist bereits in deinen Kontakten',
|
||||
['contact_added'] = 'Kontakt hinzugefügt',
|
||||
['contact_removed'] = 'the contact has been removed!',
|
||||
['number_not_assigned'] = 'diese Nummer ist nicht vergeben...',
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ Locales['en'] = {
|
||||
['message_sent'] = 'the message has been sent',
|
||||
['cannot_add_self'] = 'you can not add yourself',
|
||||
['number_in_contacts'] = 'this number is already in your contact list',
|
||||
['number_in_contacts'] = 'this number is already in your contact list',
|
||||
['contact_added'] = 'the contact has been added!',
|
||||
['contact_removed'] = 'the contact has been removed!',
|
||||
['number_not_assigned'] = 'this number is not assigned to anyone!',
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ Locales['es'] = {
|
||||
['cannot_add_self'] = 'No has podido agregar',
|
||||
['number_in_contacts'] = 'Este número ya está en tu lista de contactos',
|
||||
['contact_added'] = 'Contacto añadido',
|
||||
['contact_removed'] = 'the contact has been removed!',
|
||||
['number_not_assigned'] = 'El número no se ha añadido todavía...',
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ Locales['fr'] = {
|
||||
['cannot_add_self'] = 'vous ne pouvez pas vous ajouter vous-même',
|
||||
['number_in_contacts'] = 'ce numéro est déja dans votre liste de contacts',
|
||||
['contact_added'] = 'contact ajouté',
|
||||
['contact_removed'] = 'contact supprimé',
|
||||
['number_not_assigned'] = 'ce numéro n\'est pas attribué...',
|
||||
}
|
||||
|
||||
+56
-1
@@ -248,7 +248,8 @@ AddEventHandler('esx_phone:addPlayerContact', function(phoneNumber, contactName)
|
||||
|
||||
if foundNumber then
|
||||
|
||||
if phoneNumber == xPlayer.get('phoneNumber') then
|
||||
-- if phoneNumber == xPlayer.get('phoneNumber') then
|
||||
if false then
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('cannot_add_self'))
|
||||
else
|
||||
|
||||
@@ -299,6 +300,60 @@ AddEventHandler('esx_phone:addPlayerContact', function(phoneNumber, contactName)
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_phone:removePlayerContact')
|
||||
AddEventHandler('esx_phone:removePlayerContact', function(phoneNumber, contactName)
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local foundNumber = false
|
||||
local foundPlayer = nil
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT phone_number FROM users WHERE phone_number = @number',
|
||||
{
|
||||
['@number'] = phoneNumber
|
||||
},
|
||||
function(result)
|
||||
|
||||
if result[1] ~= nil then
|
||||
foundNumber = true
|
||||
end
|
||||
|
||||
if foundNumber then
|
||||
|
||||
local contacts = xPlayer.get('contacts')
|
||||
|
||||
for key, value in pairs(contacts) do
|
||||
if value.name == contactName and value.number == phoneNumber then
|
||||
table.remove(contacts,key)
|
||||
end
|
||||
end
|
||||
|
||||
xPlayer.set('contacts', contacts)
|
||||
|
||||
MySQL.Async.execute(
|
||||
'DELETE FROM user_contacts WHERE identifier=@identifier AND name=@name AND number=@number',
|
||||
{
|
||||
['@identifier'] = xPlayer.identifier,
|
||||
['@name'] = contactName,
|
||||
['@number'] = phoneNumber
|
||||
},
|
||||
function(rowsChanged)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('contact_removed'))
|
||||
|
||||
TriggerClientEvent('esx_phone:removeContact', _source, contactName, phoneNumber)
|
||||
end
|
||||
)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', source, _U('number_not_assigned'))
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_phone:stopDispatch')
|
||||
AddEventHandler('esx_phone:stopDispatch', function(dispatchRequestId)
|
||||
TriggerClientEvent('esx_phone:stopDispatch', -1, dispatchRequestId, GetPlayerName(source))
|
||||
|
||||
Reference in New Issue
Block a user