mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Fix: Player ready stuff (#241)
This commit is contained in:
1 parent
a103ef9b2f
commit
e05f543cb0
7 files changed
+18
-40
No files matched your search
+7
-22
@@ -10,7 +10,7 @@ import { Navigation } from './os/navigation-bar/components/Navigation';
|
|||||||
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
|
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
|
||||||
import { usePhoneService } from './os/phone/hooks/usePhoneService';
|
import { usePhoneService } from './os/phone/hooks/usePhoneService';
|
||||||
import { useApps } from './os/apps/hooks/useApps';
|
import { useApps } from './os/apps/hooks/useApps';
|
||||||
|
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||||
import { useContactsService } from './apps/contacts/hooks/useContactsService';
|
import { useContactsService } from './apps/contacts/hooks/useContactsService';
|
||||||
import { useTwitterService } from './apps/twitter/hooks/useTwitterService';
|
import { useTwitterService } from './apps/twitter/hooks/useTwitterService';
|
||||||
import { useMatchService } from './apps/match/hooks/useMatchService';
|
import { useMatchService } from './apps/match/hooks/useMatchService';
|
||||||
@@ -47,6 +47,8 @@ function Phone() {
|
|||||||
|
|
||||||
const { addAlert } = useSnackbar();
|
const { addAlert } = useSnackbar();
|
||||||
|
|
||||||
|
const Nui = useNuiRequest();
|
||||||
|
|
||||||
// Set language from local storage
|
// Set language from local storage
|
||||||
// This will only trigger on first mount & settings changes
|
// This will only trigger on first mount & settings changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -65,6 +67,10 @@ function Phone() {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
Nui.send(PhoneEvents.UI_IS_READY);
|
||||||
|
}, [Nui]);
|
||||||
|
|
||||||
useKeyboardService();
|
useKeyboardService();
|
||||||
usePhoneService();
|
usePhoneService();
|
||||||
useSimcardService();
|
useSimcardService();
|
||||||
@@ -81,14 +87,10 @@ function Phone() {
|
|||||||
|
|
||||||
const { modal: callModal } = useCallModal();
|
const { modal: callModal } = useCallModal();
|
||||||
|
|
||||||
//const { isPhoneReady } = usePhone();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<WindowSnackbar />
|
<WindowSnackbar />
|
||||||
<PhoneWrapper>
|
<PhoneWrapper>
|
||||||
{/*{isPhoneReady ? (
|
|
||||||
<>*/}
|
|
||||||
<NotificationBar />
|
<NotificationBar />
|
||||||
<div className="PhoneAppContainer">
|
<div className="PhoneAppContainer">
|
||||||
<>
|
<>
|
||||||
@@ -102,23 +104,6 @@ function Phone() {
|
|||||||
<PhoneSnackbar />
|
<PhoneSnackbar />
|
||||||
</div>
|
</div>
|
||||||
<Navigation />
|
<Navigation />
|
||||||
{/*</>
|
|
||||||
) : (
|
|
||||||
<Box
|
|
||||||
component={Paper}
|
|
||||||
height="100%"
|
|
||||||
width="100%"
|
|
||||||
display="flex"
|
|
||||||
flexDirection="column"
|
|
||||||
alignItems="center"
|
|
||||||
justifyContent="center"
|
|
||||||
>
|
|
||||||
<Typography paragraph variant="h6">
|
|
||||||
NPWD {t('INITIALIZING')}
|
|
||||||
</Typography>
|
|
||||||
<Typography paragraph>{t('GENERIC_WAIT')}</Typography>
|
|
||||||
</Box>
|
|
||||||
)}*/}
|
|
||||||
</PhoneWrapper>
|
</PhoneWrapper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ export const phoneState = {
|
|||||||
key: 'resourceConfig',
|
key: 'resourceConfig',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
/*phoneReady: atom<boolean>({
|
|
||||||
key: 'phoneReady',
|
|
||||||
default: false,
|
|
||||||
}),*/
|
|
||||||
phoneTime: atom<string>({
|
phoneTime: atom<string>({
|
||||||
key: 'phoneTime',
|
key: 'phoneTime',
|
||||||
default: null,
|
default: null,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ interface IUsePhone {
|
|||||||
export const usePhone = (): IUsePhone => {
|
export const usePhone = (): IUsePhone => {
|
||||||
const Nui = useNuiRequest();
|
const Nui = useNuiRequest();
|
||||||
const isPhoneOpen = useRecoilValue(phoneState.visibility);
|
const isPhoneOpen = useRecoilValue(phoneState.visibility);
|
||||||
//const isPhoneReady = useRecoilValue(phoneState.phoneReady);
|
|
||||||
const config = useRecoilValue(phoneState.resourceConfig);
|
const config = useRecoilValue(phoneState.resourceConfig);
|
||||||
|
|
||||||
const { removeAlerts } = useNotifications();
|
const { removeAlerts } = useNotifications();
|
||||||
@@ -34,6 +33,5 @@ export const usePhone = (): IUsePhone => {
|
|||||||
closePhone,
|
closePhone,
|
||||||
openPhone,
|
openPhone,
|
||||||
isPhoneOpen,
|
isPhoneOpen,
|
||||||
//isPhoneReady,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1,22 +1,12 @@
|
|||||||
import { useNuiEvent, useNuiRequest } from 'fivem-nui-react-lib';
|
import { useNuiEvent } from 'fivem-nui-react-lib';
|
||||||
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';
|
||||||
import { useEffect } from 'react';
|
|
||||||
|
|
||||||
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 setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
||||||
//useNuiEvent('PHONE', PhoneEvents.SET_PHONE_READY, setPhoneReady);
|
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility);
|
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility);
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setResourceConfig);
|
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setResourceConfig);
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime);
|
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime);
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ function fetchOnInitialize() {
|
|||||||
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config);
|
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.general.enableMultiChar) {
|
||||||
|
onNet(PhoneEvents.ON_INIT, () => {
|
||||||
|
fetchOnInitialize();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
|
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
|
||||||
|
|
||||||
const getCurrentGameTime = () => {
|
const getCurrentGameTime = () => {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { getSource } from '../utils/miscUtils';
|
import { getSource } from '../utils/miscUtils';
|
||||||
import PlayerService from './player.service';
|
import PlayerService from './player.service';
|
||||||
import { config } from '../server';
|
import { config, ESX } from '../server';
|
||||||
import { PlayerAddData } from './player.interfaces';
|
import { PlayerAddData } from './player.interfaces';
|
||||||
import { playerLogger } from './player.utils';
|
import { playerLogger } from './player.utils';
|
||||||
|
import { XPlayer } from 'esx.js/@types/server';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Essentially this whole file acts as a controller layer
|
* Essentially this whole file acts as a controller layer
|
||||||
|
|||||||
@@ -178,6 +178,8 @@ class _PlayerService {
|
|||||||
|
|
||||||
playerLogger.info(`New NPWD Player added through event (${src}) (${identifier})`);
|
playerLogger.info(`New NPWD Player added through event (${src}) (${identifier})`);
|
||||||
playerLogger.debug(player);
|
playerLogger.debug(player);
|
||||||
|
|
||||||
|
emitNet(PhoneEvents.ON_INIT, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user