mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
cleanup(phone/gen): Added NUI event enums for phone events
This commit is contained in:
1 parent
e6deff23da
commit
9610891a04
7 files changed
+29
-18
No files matched your search
+3
-2
@@ -33,6 +33,7 @@ import WindowSnackbar from './ui/components/WindowSnackbar';
|
|||||||
import { usePhone } from './os/phone/hooks/usePhone';
|
import { usePhone } from './os/phone/hooks/usePhone';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useSnackbar } from './ui/hooks/useSnackbar';
|
import { useSnackbar } from './ui/hooks/useSnackbar';
|
||||||
|
import { PhoneEvents } from '../../typings/phone';
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
@@ -154,12 +155,12 @@ export default Phone;
|
|||||||
InjectDebugData([
|
InjectDebugData([
|
||||||
{
|
{
|
||||||
app: 'PHONE',
|
app: 'PHONE',
|
||||||
method: 'setVisibility',
|
method: PhoneEvents.SET_VISIBILITY,
|
||||||
data: true,
|
data: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
app: 'PHONE',
|
app: 'PHONE',
|
||||||
method: 'setPhoneReady',
|
method: PhoneEvents.SET_PHONE_READY,
|
||||||
data: true,
|
data: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { phoneState } from './state';
|
import { phoneState } from './state';
|
||||||
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
|
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
|
||||||
|
import { PhoneEvents } from '../../../../../typings/phone';
|
||||||
|
|
||||||
export const usePhoneService = () => {
|
export const usePhoneService = () => {
|
||||||
const setVisibility = useSetRecoilState(phoneState.visibility);
|
const setVisibility = useSetRecoilState(phoneState.visibility);
|
||||||
const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig);
|
const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig);
|
||||||
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
||||||
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
||||||
useNuiEvent('PHONE', 'setVisibility', setVisibility);
|
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility);
|
||||||
useNuiEvent('PHONE', 'setPhoneReady', setPhoneReady);
|
useNuiEvent('PHONE', PhoneEvents.SET_PHONE_READY, setPhoneReady);
|
||||||
useNuiEvent('PHONE', 'phoneConfig', setPhoneConfig);
|
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setPhoneConfig);
|
||||||
useNuiEvent('PHONE', 'setTime', setPhoneTime);
|
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime);
|
||||||
};
|
};
|
||||||
@@ -3,6 +3,7 @@ import { useSetRecoilState } from 'recoil';
|
|||||||
import { simcardState } from './state';
|
import { simcardState } from './state';
|
||||||
import { useSimcard } from './useSimcard';
|
import { useSimcard } from './useSimcard';
|
||||||
import InjectDebugData from '../../debug/InjectDebugData';
|
import InjectDebugData from '../../debug/InjectDebugData';
|
||||||
|
import { PhoneEvents } from '../../../../../typings/phone';
|
||||||
|
|
||||||
InjectDebugData([
|
InjectDebugData([
|
||||||
{
|
{
|
||||||
@@ -14,6 +15,6 @@ InjectDebugData([
|
|||||||
|
|
||||||
export const useSimcardService = () => {
|
export const useSimcardService = () => {
|
||||||
const setNumber = useSetRecoilState(simcardState.number);
|
const setNumber = useSetRecoilState(simcardState.number);
|
||||||
useNuiEvent('SIMCARD', 'setNumber', setNumber);
|
useNuiEvent('SIMCARD', PhoneEvents.SET_NUMBER, setNumber);
|
||||||
return useSimcard();
|
return useSimcard();
|
||||||
};
|
};
|
||||||
@@ -25,8 +25,8 @@ function fetchOnInitialize() {
|
|||||||
emitNet(ContactEvents.GET_CONTACTS);
|
emitNet(ContactEvents.GET_CONTACTS);
|
||||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||||
sendMessage('PHONE', 'setPhoneReady', isPhoneReady);
|
sendMessage('PHONE', PhoneEvents.SET_PHONE_READY, isPhoneReady);
|
||||||
sendMessage('PHONE', 'phoneConfig', config);
|
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
|
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
|
||||||
@@ -55,14 +55,14 @@ const showPhone = async (): Promise<void> => {
|
|||||||
await phoneOpenAnim(); // Animation starts before the phone is open
|
await phoneOpenAnim(); // Animation starts before the phone is open
|
||||||
emitNet('phone:getCredentials');
|
emitNet('phone:getCredentials');
|
||||||
SetCursorLocation(0.9, 0.922); //Experimental
|
SetCursorLocation(0.9, 0.922); //Experimental
|
||||||
sendMessage('PHONE', 'setVisibility', true);
|
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true);
|
||||||
sendMessage('PHONE', 'setTime', time);
|
sendMessage('PHONE', PhoneEvents.SET_TIME, time);
|
||||||
SetNuiFocus(true, true);
|
SetNuiFocus(true, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const hidePhone = async (): Promise<void> => {
|
const hidePhone = async (): Promise<void> => {
|
||||||
isPhoneOpen = false;
|
isPhoneOpen = false;
|
||||||
sendMessage('PHONE', 'setVisibility', false);
|
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
|
||||||
await phoneCloseAnim();
|
await phoneCloseAnim();
|
||||||
SetNuiFocus(false, false);
|
SetNuiFocus(false, false);
|
||||||
};
|
};
|
||||||
@@ -115,15 +115,15 @@ onNet(PhoneEvents.PLAYER_IS_READY, fetchOnInitialize);
|
|||||||
|
|
||||||
AddEventHandler('onResourceStop', function (resource: string) {
|
AddEventHandler('onResourceStop', function (resource: string) {
|
||||||
if (resource === GetCurrentResourceName()) {
|
if (resource === GetCurrentResourceName()) {
|
||||||
sendMessage('PHONE', 'setVisibility', false);
|
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
|
||||||
SetNuiFocus(false, false);
|
SetNuiFocus(false, false);
|
||||||
removePhoneProp(); //Deletes the phone incase it was attached.
|
removePhoneProp(); //Deletes the phone incase it was attached.
|
||||||
ClearPedTasks(PlayerPedId()); //Leave here until launch as it'll fix any stuck animations.
|
ClearPedTasks(PlayerPedId()); //Leave here until launch as it'll fix any stuck animations.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet('phone:sendCredentials', (number: string) => {
|
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
|
||||||
sendMessage('SIMCARD', 'setNumber', number);
|
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number);
|
||||||
});
|
});
|
||||||
|
|
||||||
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { PhotoEvents } from '../../typings/photo';
|
import { PhotoEvents } from '../../typings/photo';
|
||||||
import { Delay } from '../utils/fivem';
|
import { Delay } from '../utils/fivem';
|
||||||
import { sendMessage, sendCameraEvent } from '../utils/messages';
|
import { sendMessage, sendCameraEvent } from '../utils/messages';
|
||||||
|
import { PhoneEvents } from '../../typings/phone';
|
||||||
const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none');
|
const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none');
|
||||||
|
|
||||||
const exp = (global as any).exports;
|
const exp = (global as any).exports;
|
||||||
@@ -9,12 +10,12 @@ let inCameraMode = false;
|
|||||||
|
|
||||||
function closePhoneTemp() {
|
function closePhoneTemp() {
|
||||||
SetNuiFocus(false, false);
|
SetNuiFocus(false, false);
|
||||||
sendMessage('PHONE', 'setVisibility', false);
|
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openPhoneTemp() {
|
function openPhoneTemp() {
|
||||||
SetNuiFocus(true, true);
|
SetNuiFocus(true, true);
|
||||||
sendMessage('PHONE', 'setVisibility', true);
|
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CellFrontCamActivate(activate: boolean) {
|
function CellFrontCamActivate(activate: boolean) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { getIdentifier, getSource } from './functions';
|
import { getIdentifier, getSource } from './functions';
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
|
import { PhoneEvents } from '../../typings/phone';
|
||||||
|
|
||||||
interface Credentials {
|
interface Credentials {
|
||||||
phone_number: string;
|
phone_number: string;
|
||||||
@@ -19,7 +20,7 @@ onNet('phone:getCredentials', async () => {
|
|||||||
try {
|
try {
|
||||||
const identifier = getIdentifier(_source);
|
const identifier = getIdentifier(_source);
|
||||||
const number = await getCredentials(identifier);
|
const number = await getCredentials(identifier);
|
||||||
emitNet('phone:sendCredentials', _source, number);
|
emitNet(PhoneEvents.SEND_CREDENTIALS, _source, number);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
mainLogger.error(`Failed to get a number, ${e.message}`, {
|
mainLogger.error(`Failed to get a number, ${e.message}`, {
|
||||||
source: _source,
|
source: _source,
|
||||||
|
|||||||
@@ -11,5 +11,11 @@ export enum PhoneEvents {
|
|||||||
OPEN_PHONE = 'npwd:open',
|
OPEN_PHONE = 'npwd:open',
|
||||||
CLOSE_PHONE = 'npwd:close',
|
CLOSE_PHONE = 'npwd:close',
|
||||||
SET_ALERT = 'npwd:setAlert',
|
SET_ALERT = 'npwd:setAlert',
|
||||||
|
SET_VISIBILITY = 'npwd:setVisibility',
|
||||||
SET_NOTIFICATION = 'npwd:setNotification',
|
SET_NOTIFICATION = 'npwd:setNotification',
|
||||||
|
SET_NUMBER = 'npwd:setNumber',
|
||||||
|
SET_PHONE_READY = 'npwd:phoneReady',
|
||||||
|
SET_CONFIG = 'npwd:setPhoneConfig',
|
||||||
|
SET_TIME = 'npwd:setGameTime',
|
||||||
|
SEND_CREDENTIALS = 'npwd:sendCredentials',
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user