diff --git a/phone/src/os/notifications/components/NotificationBar.tsx b/phone/src/os/notifications/components/NotificationBar.tsx
index 561eb75..aee3d09 100644
--- a/phone/src/os/notifications/components/NotificationBar.tsx
+++ b/phone/src/os/notifications/components/NotificationBar.tsx
@@ -16,6 +16,7 @@ import ArrowDropUpIcon from '@material-ui/icons/ArrowDropUp';
import Default from '../../../config/default.json';
import { useNotifications } from '../hooks/useNotifications';
import { NotificationItem } from './NotificationItem';
+import usePhoneTime from '../../phone/hooks/usePhoneTime';
const useStyles = makeStyles((theme) => ({
root: {
@@ -74,6 +75,8 @@ export const NotificationBar = () => {
setBarUncollapsed,
} = useNotifications();
+ const time = usePhoneTime();
+
return (
<>
{
))}
+ {time && (
+
+
+ {time}
+
+
+ )}
diff --git a/phone/src/os/phone/hooks/state.ts b/phone/src/os/phone/hooks/state.ts
index d12133c..522d618 100644
--- a/phone/src/os/phone/hooks/state.ts
+++ b/phone/src/os/phone/hooks/state.ts
@@ -13,4 +13,8 @@ export const phoneState = {
key: 'phoneReady',
default: false,
}),
+ phoneTime: atom({
+ key: 'phoneTime',
+ default: null,
+ }),
};
diff --git a/phone/src/os/phone/hooks/usePhoneService.ts b/phone/src/os/phone/hooks/usePhoneService.ts
index 957b153..0500dfe 100644
--- a/phone/src/os/phone/hooks/usePhoneService.ts
+++ b/phone/src/os/phone/hooks/usePhoneService.ts
@@ -6,7 +6,9 @@ export const usePhoneService = () => {
const setVisibility = useSetRecoilState(phoneState.visibility);
const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig);
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
+ const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
useNuiEvent('PHONE', 'setVisibility', setVisibility);
useNuiEvent('PHONE', 'setPhoneReady', setPhoneReady);
useNuiEvent('PHONE', 'phoneConfig', setPhoneConfig);
+ useNuiEvent('PHONE', 'setTime', setPhoneTime);
};
diff --git a/phone/src/os/phone/hooks/usePhoneTime.ts b/phone/src/os/phone/hooks/usePhoneTime.ts
new file mode 100644
index 0000000..5f36df6
--- /dev/null
+++ b/phone/src/os/phone/hooks/usePhoneTime.ts
@@ -0,0 +1,8 @@
+import { useRecoilValue } from 'recoil';
+import { phoneState } from './state';
+
+const usePhoneTime = () => {
+ return useRecoilValue(phoneState.phoneTime);
+};
+
+export default usePhoneTime;
diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts
index 8fcdbac..5d1080a 100644
--- a/resources/client/cl_main.ts
+++ b/resources/client/cl_main.ts
@@ -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 => {
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);