feat(phone): Added a game time indicator to top bar (#176)

This commit is contained in:
Taso authored and GitHub committed 2021-03-26 13:30:09 -04:00
1 parent 6b865f2e73
commit 853b335ef9
5 files changed
+44

No files matched your search

+20
View File
@@ -31,6 +31,18 @@ function fetchOnInitialize() {
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
const getCurrentGameTime = () => {
let hour: string | number = GetClockHours();
let minute: string | number = GetClockMinutes();
// Format time if need be
if (hour < 10) hour = `0${hour}`;
if (minute < 10) minute = `0${minute}`;
return `${hour}:${minute}`;
};
/* * * * * * * * * * * * *
*
* Phone Visibility Handling
@@ -39,10 +51,12 @@ RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
const showPhone = async (): Promise<void> => {
isPhoneOpen = true;
const time = getCurrentGameTime();
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);
SetNuiFocus(true, true);
};
@@ -176,3 +190,9 @@ on(`__cfx_nui:${PhoneEvents.CLOSE_PHONE}`, async (data: any, cb: Function) => {
// }
// }
// });
// Will update the phone's time even while its open
// setInterval(() => {
// const time = getCurrentGameTime()
// sendMessage('PHONE', 'setTime', time)
// }, 2000);