mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Fix: Workaround for ESX errors pertaining to player loading (#153)
* Set phone ready before sending any init events + Show initializing phone message if not ready yet * Send phone ready to nui
This commit is contained in:
1 parent
6e72e2c50e
commit
1a09fa57ae
7 files changed
+76
-31
No files matched your search
@@ -3,6 +3,26 @@ import events from '../utils/events';
|
||||
import { phoneCloseAnim, phoneOpenAnim, removePhoneProp } from './functions';
|
||||
|
||||
let isPhoneOpen = false;
|
||||
let isPhoneReady = false;
|
||||
|
||||
/* * * * * * * * * * * * *
|
||||
*
|
||||
* Phone initialize data
|
||||
*
|
||||
* * * * * * * * * * * * */
|
||||
function fetchOnInitialize() {
|
||||
isPhoneReady = true;
|
||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS);
|
||||
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE);
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'PHONE',
|
||||
method: 'setPhoneReady',
|
||||
data: true,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
|
||||
|
||||
@@ -90,6 +110,8 @@ async function Phone(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
onNet('esx:playerLoaded', fetchOnInitialize);
|
||||
|
||||
AddEventHandler('onResourceStop', function (resource: string) {
|
||||
if (resource === GetCurrentResourceName()) {
|
||||
SendNuiMessage(
|
||||
@@ -116,17 +138,13 @@ onNet('phone:sendCredentials', (number: string) => {
|
||||
});
|
||||
|
||||
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
||||
// ^ AND WHAT ARE YOU GOING TO DO HUH? - KIDZ
|
||||
|
||||
/* * * * * * * * * * * * *
|
||||
*
|
||||
* NUI Service Callback Registration
|
||||
*
|
||||
* * * * * * * * * * * * */
|
||||
|
||||
function fetchOnInitialize() {
|
||||
emitNet(events.CONTACTS_GET_CONTACTS);
|
||||
}
|
||||
|
||||
RegisterNuiCallbackType(events.OPEN_APP_LISTINGS);
|
||||
on(`__cfx_nui:${events.OPEN_APP_LISTINGS}`, (data: any, cb: Function) => {
|
||||
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||
|
||||
Reference in new issue
Block a user