Skip to content

Commit

Permalink
chore: ran prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximus7474 committed Oct 29, 2024
1 parent 1f2b6c7 commit 569b5b8
Show file tree
Hide file tree
Showing 6 changed files with 364 additions and 330 deletions.
37 changes: 18 additions & 19 deletions src/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { cache, sleep } from '@overextended/ox_lib/client';
import { Character, NewCharacter } from '@overextended/ox_core';

const SPAWN_LOCATION = JSON.parse(GetConvar('ox:spawnLocation', "[-258.211, -293.077, 21.6132, 206.0]")) as [number, number, number, number];
const SPAWN_LOCATION = JSON.parse(GetConvar('ox:spawnLocation', '[-258.211, -293.077, 21.6132, 206.0]')) as [
number,
number,
number,
number,
];
const CHARACTER_SLOTS: number = GetConvarInt('ox:characterSlots', 1);

let uiLoaded: boolean = false;

onNet('ox:startCharacterSelect', async (_userId: number, characters: Character[]) => {

while (!uiLoaded) await sleep(5);

SendNUIMessage({
action: 'setData',
data: {
characters: characters
characters: characters,
},
});

Expand All @@ -27,11 +31,7 @@ onNet('ox:startCharacterSelect', async (_userId: number, characters: Character[]

/* Code taken from ox_core/src/client/spawn.ts */
const character = characters[0];
const [x, y, z]: number[] = [
SPAWN_LOCATION[0],
SPAWN_LOCATION[1],
SPAWN_LOCATION[2],
];
const [x, y, z]: number[] = [SPAWN_LOCATION[0], SPAWN_LOCATION[1], SPAWN_LOCATION[2]];
const heading = SPAWN_LOCATION[3];

RequestCollisionAtCoord(x, y, z);
Expand All @@ -46,20 +46,20 @@ onNet('ox:startCharacterSelect', async (_userId: number, characters: Character[]
action: 'setVisible',
data: {
visible: true,
page: 'identity'
page: 'identity',
},
});

return
return;
}

SetNuiFocus(true, true)
SetNuiFocus(true, true);

SendNUIMessage({
action: 'setVisible',
data: {
visible: true,
page: 'multichar'
page: 'multichar',
},
});

Expand All @@ -69,12 +69,11 @@ onNet('ox:startCharacterSelect', async (_userId: number, characters: Character[]
RegisterNuiCallback('mps-multichar:setConfig', (data: boolean, cb: (data: unknown) => void) => {
uiLoaded = data;
cb({
maxSlots: CHARACTER_SLOTS
})
})
maxSlots: CHARACTER_SLOTS,
});
});

RegisterNuiCallback('mps-multichar:registerIdentity', (data: NewCharacter, cb: (data: unknown) => void) => {

SwitchInPlayer(PlayerPedId());
SetGameplayCamRelativeHeading(0);

Expand All @@ -83,7 +82,7 @@ RegisterNuiCallback('mps-multichar:registerIdentity', (data: NewCharacter, cb: (
SendNUIMessage({
action: 'setVisible',
data: {
visible: false
visible: false,
},
});

Expand Down Expand Up @@ -113,11 +112,11 @@ RegisterNuiCallback('mps-multichar:selectedCharacter', (character: Character, cb
SendNUIMessage({
action: 'setVisible',
data: {
visible: false
visible: false,
},
});

emitNet('ox:setActiveCharacter', character.charId);

cb(true);
});
});
30 changes: 15 additions & 15 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ function App() {
const [characters, setCharacters] = useState<Character[]>([]);

if (!loaded) {
fetchNui('mps-multichar:setConfig', true, {data: {maxSlots: 5}})
.then(r => {
setLoaded(true);
setCharSlots(r.maxSlots);
})
.catch(err => console.error('Unable to get config', err));
fetchNui('mps-multichar:setConfig', true, { data: { maxSlots: 5 } })
.then((r) => {
setLoaded(true);
setCharSlots(r.maxSlots);
})
.catch((err) => console.error('Unable to get config', err));
}

useNuiEvent('setVisible', (data: { visible?: boolean, page?: string }) => {
useNuiEvent('setVisible', (data: { visible?: boolean; page?: string }) => {
setVisible(data.visible || false);
if (data.page) setPage(data.page);
});

useNuiEvent('setData', (data: {characters?: Character[]}) => {
useNuiEvent('setData', (data: { characters?: Character[] }) => {
if (data.characters) setCharacters(data.characters);
});

Expand All @@ -39,19 +39,19 @@ function App() {
setCharacters([
{
charId: 1,
stateId: "IJ0221",
firstName: "Maximus",
lastName: "Prime",
stateId: 'IJ0221',
firstName: 'Maximus',
lastName: 'Prime',
x: 411.69232177734375,
y: -1628.4000244140625,
z: 29.2799072265625,
heading: 243.77952575683594,
lastPlayed: "26/10/2024"
}
])
lastPlayed: '26/10/2024',
},
]);
}, 1000);
}, []);
};
}

return (
<>
Expand Down
6 changes: 3 additions & 3 deletions web/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import '@mantine/core/styles.css';
import './index.css'
import './index.css';

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import { MantineProvider } from '@mantine/core'
import { MantineProvider } from '@mantine/core';
import { isEnvBrowser } from './utils/misc.ts';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<MantineProvider defaultColorScheme='dark'>
<MantineProvider defaultColorScheme="dark">
<App />
</MantineProvider>
</React.StrictMode>
Expand Down
Loading

0 comments on commit 569b5b8

Please sign in to comment.