feat(phone/client): fetch photos when opening camera app

This commit is contained in:
Christopher committed 2020-12-04 23:06:56 +01:00
1 parent d671ece127
commit f7ffd461ac
1 file changed
+51 -19
+51 -19
View File
@@ -226,6 +226,25 @@ setTick(() => {
} }
}); });
// setTick(() => {
// if (isPhoneOpen) {
// DisableControlAction(0, 1, true)
// DisableControlAction(0, 2, true)
// DisableControlAction(0, 24, true)
// DisableControlAction(0, 257, true)
// DisableControlAction(0, 25, true)
// DisableControlAction(0, 263, true)
// } else {
// EnableControlAction(0, 1, true)
// EnableControlAction(0, 2, true)
// EnableControlAction(0, 24, true)
// EnableControlAction(0, 257, true)
// EnableControlAction(0, 25, true)
// EnableControlAction(0, 263, true)
// }
// })
async function Phone() { async function Phone() {
if (config.PhoneAsItem) { if (config.PhoneAsItem) {
console.log("CONFIG ON"); console.log("CONFIG ON");
@@ -247,6 +266,8 @@ async function Phone() {
); );
sendPhoneConfig(); sendPhoneConfig();
SetNuiFocus(true, true); SetNuiFocus(true, true);
//SetNuiFocusKeepInput(true)
} else { } else {
isPhoneOpen = false; isPhoneOpen = false;
SendNuiMessage( SendNuiMessage(
@@ -258,6 +279,8 @@ async function Phone() {
}) })
); );
SetNuiFocus(false, false); SetNuiFocus(false, false);
//SetNuiFocusKeepInput(false)
await phoneCloseAnim(); // Animation starts after the UI is closed. await phoneCloseAnim(); // Animation starts after the UI is closed.
} }
} else { } else {
@@ -282,6 +305,8 @@ async function Phone() {
); );
sendPhoneConfig(); sendPhoneConfig();
SetNuiFocus(true, true); SetNuiFocus(true, true);
//SetNuiFocusKeepInput(true)
} else { } else {
isPhoneOpen = false; isPhoneOpen = false;
SendNuiMessage( SendNuiMessage(
@@ -293,6 +318,8 @@ async function Phone() {
}) })
); );
SetNuiFocus(false, false); SetNuiFocus(false, false);
//SetNuiFocusKeepInput(false)
await phoneCloseAnim(); // Animation starts after the UI is closed. await phoneCloseAnim(); // Animation starts after the UI is closed.
} }
} }
@@ -322,6 +349,11 @@ on(`__cfx_nui:${events.OPEN_APP_BANK}`, () => {
emitNet(events.BANK_GET_CREDENTIALS); emitNet(events.BANK_GET_CREDENTIALS);
}) })
RegisterNuiCallbackType(events.OPEN_APP_CAMERA);
on(`__cfx_nui:${events.OPEN_APP_CAMERA}`, () => {
emitNet(events.CAMERA_FETCH_PHOTOS);
})
RegisterCommand( RegisterCommand(
"phone", "phone",
() => { () => {
@@ -367,25 +399,25 @@ function countPhone(cb: any) {
let destroyedPhone = false; let destroyedPhone = false;
setTick(async () => { // setTick(async () => {
while (config.SwimDestroy) { // while (config.SwimDestroy) {
await Delay(config.RunRate * 1000); // await Delay(config.RunRate * 1000);
if (IsPedSwimming(PlayerPedId())) { // if (IsPedSwimming(PlayerPedId())) {
let chance = Math.floor(Math.random() * 100 + 1); // let chance = Math.floor(Math.random() * 100 + 1);
if (chance <= config.DestoryChance) { // if (chance <= config.DestoryChance) {
countPhone((countPhone: boolean) => { // countPhone((countPhone: boolean) => {
if (countPhone) { // if (countPhone) {
ESX.ShowNotification("Your phone is ruined from the water!"); // ESX.ShowNotification("Your phone is ruined from the water!");
destroyedPhone = true; // destroyedPhone = true;
} // }
}); // });
} // }
if (destroyedPhone) { // if (destroyedPhone) {
await Delay(config.DestroyPhoneReCheck * 60000); // await Delay(config.DestroyPhoneReCheck * 60000);
} // }
} // }
} // }
}); // });
onNet("phone:sendCredentials", (number: string) => { onNet("phone:sendCredentials", (number: string) => {
SendNuiMessage( SendNuiMessage(