mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Feat(Contacts): Changed to server side to TS
This commit is contained in:
1 parent
bd37aa5da7
commit
77802b1524
2 files changed
+21
-28
No files matched your search
@@ -1,28 +0,0 @@
|
|||||||
ESX = nil
|
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
|
||||||
while ESX == nil do
|
|
||||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
|
||||||
Citizen.Wait(0)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent('phone:sendContacts')
|
|
||||||
AddEventHandler('phone:sendContacts', function()
|
|
||||||
ESX.TriggerServerCallback('phone:getContacts', function(contacts)
|
|
||||||
SendNUIMessage(
|
|
||||||
{
|
|
||||||
app = 'BANK',
|
|
||||||
method = 'setContacts',
|
|
||||||
data = contacts
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNUICallback('contacts:add', function(data)
|
|
||||||
local display = data.name
|
|
||||||
local number = data.number
|
|
||||||
TriggerServerEvent('phone:addContacts', display, number)
|
|
||||||
TriggerEvent('phone:sendContacts')
|
|
||||||
end)
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { ESX } from '../client/client';
|
||||||
|
import events from '../utils/events';
|
||||||
|
|
||||||
|
onNet(events.CONTACTS_SEND_CONTACTS, () => {
|
||||||
|
ESX.TriggerServerCallback(events.CONTACTS_GET_CONTACTS, (contacts: any) => {
|
||||||
|
SendNuiMessage(
|
||||||
|
JSON.stringify({
|
||||||
|
app: 'CONTACTS',
|
||||||
|
method: 'setContacts',
|
||||||
|
data: contacts
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterNuiCallbackType(events.CONTACTS_ADD_CONTACT_NUI);
|
||||||
|
on(`__cfx_nui:${events.CONTACTS_ADD_CONTACT_NUI}`, (data: any) => {
|
||||||
|
const display = data.name;
|
||||||
|
const number = data.number;
|
||||||
|
emitNet(events.CONTACTS_ADD_CONTACT, display, number);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user