mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
fix(init): remove player/ui ready events
This commit is contained in:
1 parent
c5aaf32e5d
commit
f89ffc3060
4 files changed
+6
-23
No files matched your search
@@ -1,17 +1,9 @@
|
|||||||
import { useNuiEvent, useNuiRequest } from 'fivem-nui-react-lib';
|
import { useNuiEvent } from 'fivem-nui-react-lib';
|
||||||
import { useEffect } from 'react';
|
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { PhoneEvents } from '../../../../../typings/phone';
|
import { PhoneEvents } from '../../../../../typings/phone';
|
||||||
import { phoneState } from './state';
|
import { phoneState } from './state';
|
||||||
|
|
||||||
export const usePhoneService = () => {
|
export const usePhoneService = () => {
|
||||||
const { send } = useNuiRequest();
|
|
||||||
|
|
||||||
// Let client know UI is ready to accept events
|
|
||||||
useEffect(() => {
|
|
||||||
send(PhoneEvents.UI_IS_READY);
|
|
||||||
}, [send]);
|
|
||||||
|
|
||||||
const setVisibility = useSetRecoilState(phoneState.visibility);
|
const setVisibility = useSetRecoilState(phoneState.visibility);
|
||||||
const setResourceConfig = useSetRecoilState(phoneState.resourceConfig);
|
const setResourceConfig = useSetRecoilState(phoneState.resourceConfig);
|
||||||
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
||||||
|
|||||||
@@ -131,13 +131,8 @@ onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
|
|||||||
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number);
|
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number);
|
||||||
});
|
});
|
||||||
|
|
||||||
RegisterNuiCallbackType(PhoneEvents.UI_IS_READY);
|
onNet(PhoneEvents.ON_INIT, () => {
|
||||||
on(`__cfx_nui:${PhoneEvents.UI_IS_READY}`, (_data: any, cb: Function) => {
|
fetchOnInitialize();
|
||||||
isUiReady = true;
|
|
||||||
if (isPlayerReady) {
|
|
||||||
fetchOnInitialize();
|
|
||||||
}
|
|
||||||
cb();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class _PlayerService {
|
|||||||
playerLogger.debug(newPlayer);
|
playerLogger.debug(newPlayer);
|
||||||
|
|
||||||
// Emit to client that player is ready
|
// Emit to client that player is ready
|
||||||
emitNet(PhoneEvents.PLAYER_IS_READY, pSource, true);
|
emitNet(PhoneEvents.ON_INIT, pSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,7 +183,7 @@ class _PlayerService {
|
|||||||
playerLogger.debug(player);
|
playerLogger.debug(player);
|
||||||
|
|
||||||
// Emit to client that player is ready
|
// Emit to client that player is ready
|
||||||
emitNet(PhoneEvents.PLAYER_IS_READY, src, true);
|
emitNet(PhoneEvents.ON_INIT, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,11 +210,6 @@ class _PlayerService {
|
|||||||
this.deletePlayerFromMaps(src);
|
this.deletePlayerFromMaps(src);
|
||||||
|
|
||||||
playerLogger.info(`Unloaded NPWD Player, source: (${src})`);
|
playerLogger.info(`Unloaded NPWD Player, source: (${src})`);
|
||||||
|
|
||||||
// We emit PLAYER_IS_READY false if the player wasn't disconnected
|
|
||||||
if (!playerDropped) {
|
|
||||||
emitNet(PhoneEvents.PLAYER_IS_READY, src, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export enum PhoneEvents {
|
|||||||
SET_CONFIG = 'npwd:setPhoneConfig',
|
SET_CONFIG = 'npwd:setPhoneConfig',
|
||||||
SET_TIME = 'npwd:setGameTime',
|
SET_TIME = 'npwd:setGameTime',
|
||||||
SEND_CREDENTIALS = 'npwd:sendCredentials',
|
SEND_CREDENTIALS = 'npwd:sendCredentials',
|
||||||
|
ON_INIT = 'npwd:onInit',
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to standardize the server response
|
// Used to standardize the server response
|
||||||
|
|||||||
Reference in new issue
Block a user