Skip to content

Commit 341578b

Browse files
chore(base): toggle phone ingame
1 parent 5996ff8 commit 341578b

File tree

6 files changed

+67
-7
lines changed

6 files changed

+67
-7
lines changed

pnpm-lock.yaml

+37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/move.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ echo "Moving $name to destination $destination"
1818
source="./dist"
1919

2020
# Move source to destination
21-
cp -r $source "$destination/$name"
21+
cp -Tr $source "$destination/$name"
2222

src/client/index.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
let isFocused = false;
2-
const exps = global.exports;
1+
let isPhoneOpenState = false;
32

43
RegisterCommand(
5-
'mock-command',
4+
'npwd-toggle-phone',
65
() => {
7-
console.log('calling mock command');
6+
if (isPhoneOpenState) {
7+
isPhoneOpenState = false;
8+
global.SendNUIMessage({ type: 'SET_PHONE_OPEN', payload: false });
9+
SetNuiFocus(false, false);
10+
} else {
11+
isPhoneOpenState = true;
12+
global.SendNUIMessage({ type: 'SET_PHONE_OPEN', payload: true });
13+
SetNuiFocus(true, true);
14+
}
815
},
916
false,
1017
);
18+
19+
RegisterKeyMapping('npwd-toggle-phone', 'Open Phone', 'keyboard', 'M');

src/ui/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@tanstack/react-query-devtools": "4",
1515
"react": "^18.3.1",
1616
"react-dom": "^18.3.1",
17+
"react-fivem-hooks": "^1.0.3",
1718
"react-router": "^6.26.1",
1819
"react-router-dom": "^6.26.1"
1920
},

src/ui/src/App.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useEffect } from 'react';
55
import { setTheme } from './utils/theme';
66
import { Footer } from './components/Main/Footer';
77
import { Header } from './components/Main/Header';
8+
import { useNuiEvent } from 'react-fivem-hooks';
89

910
export const lightTheme = {
1011
textColor: {
@@ -35,6 +36,15 @@ function App() {
3536
: setTheme(lightTheme);
3637
}, []);
3738

39+
const { data: isOpen } = useNuiEvent<boolean>({
40+
event: 'SET_PHONE_OPEN',
41+
defaultValue: false,
42+
});
43+
44+
if (!isOpen) {
45+
return null;
46+
}
47+
3848
return (
3949
<Frame>
4050
<main className="flex flex-col flex-1 overflow-hidden">

src/ui/src/Providers.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { QueryCache, QueryClient, QueryClientProvider } from '@tanstack/react-query';
22
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
33
import { PropsWithChildren } from 'react';
4+
import { NuiProvider } from 'react-fivem-hooks';
45

56
export const Providers = ({ children }: PropsWithChildren) => {
67
const queryClient = new QueryClient({
@@ -19,8 +20,10 @@ export const Providers = ({ children }: PropsWithChildren) => {
1920

2021
return (
2122
<QueryClientProvider client={queryClient}>
22-
{/* <ReactQueryDevtools initialIsOpen={false} /> */}
23-
{children}
23+
<NuiProvider>
24+
{/* <ReactQueryDevtools initialIsOpen={false} /> */}
25+
{children}
26+
</NuiProvider>
2427
</QueryClientProvider>
2528
);
2629
};

0 commit comments

Comments
 (0)