cleanup(phone/gen): Added NUI event enums for phone events

This commit is contained in:
Taso committed 2021-04-01 13:42:48 -04:00
1 parent e6deff23da
commit 9610891a04
7 files changed
+29 -18

No files matched your search

+8 -8
View File
@@ -25,8 +25,8 @@ function fetchOnInitialize() {
emitNet(ContactEvents.GET_CONTACTS);
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
sendMessage('PHONE', 'setPhoneReady', isPhoneReady);
sendMessage('PHONE', 'phoneConfig', config);
sendMessage('PHONE', PhoneEvents.SET_PHONE_READY, isPhoneReady);
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config);
}
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
@@ -55,14 +55,14 @@ const showPhone = async (): Promise<void> => {
await phoneOpenAnim(); // Animation starts before the phone is open
emitNet('phone:getCredentials');
SetCursorLocation(0.9, 0.922); //Experimental
sendMessage('PHONE', 'setVisibility', true);
sendMessage('PHONE', 'setTime', time);
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true);
sendMessage('PHONE', PhoneEvents.SET_TIME, time);
SetNuiFocus(true, true);
};
const hidePhone = async (): Promise<void> => {
isPhoneOpen = false;
sendMessage('PHONE', 'setVisibility', false);
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
await phoneCloseAnim();
SetNuiFocus(false, false);
};
@@ -115,15 +115,15 @@ onNet(PhoneEvents.PLAYER_IS_READY, fetchOnInitialize);
AddEventHandler('onResourceStop', function (resource: string) {
if (resource === GetCurrentResourceName()) {
sendMessage('PHONE', 'setVisibility', false);
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
SetNuiFocus(false, false);
removePhoneProp(); //Deletes the phone incase it was attached.
ClearPedTasks(PlayerPedId()); //Leave here until launch as it'll fix any stuck animations.
}
});
onNet('phone:sendCredentials', (number: string) => {
sendMessage('SIMCARD', 'setNumber', number);
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number);
});
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
+3 -2
View File
@@ -1,6 +1,7 @@
import { PhotoEvents } from '../../typings/photo';
import { Delay } from '../utils/fivem';
import { sendMessage, sendCameraEvent } from '../utils/messages';
import { PhoneEvents } from '../../typings/phone';
const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none');
const exp = (global as any).exports;
@@ -9,12 +10,12 @@ let inCameraMode = false;
function closePhoneTemp() {
SetNuiFocus(false, false);
sendMessage('PHONE', 'setVisibility', false);
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
}
function openPhoneTemp() {
SetNuiFocus(true, true);
sendMessage('PHONE', 'setVisibility', true);
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true);
}
function CellFrontCamActivate(activate: boolean) {