Merge pull request #1661 from Zykem/feat/nuiready-await

fix(esx_multicharacter): Await nuiReady before setting up characters
This commit is contained in:
Kenshin13
2025-07-13 13:02:26 +02:00
committed by GitHub
7 changed files with 4081 additions and 29 deletions
+14 -3
View File
@@ -1,5 +1,6 @@
CreateThread(function()
local nuiReady = false
CreateThread(function()
while not ESX.PlayerLoaded do
Wait(100)
@@ -15,6 +16,12 @@ end)
-- Events
ESX.SecureNetEvent("esx_multicharacter:SetupUI", function(data, slots)
if not nuiReady then
print('[WARNING]', 'NUI not ready yet, awaiting...')
ESX.Await(function()
return nuiReady == true
end, 'NUI Failed to load after 10000ms', 10000)
end
Multicharacter:SetupUI(data, slots)
end)
@@ -43,7 +50,11 @@ if Config.Relog then
ESX.SetTimeout(10000, function()
Multicharacter.canRelog = true
end)
end
end,false)
end, false)
end
RegisterNuiCallback('nuiReady', function(_, cb)
nuiReady = true
cb(1)
end)
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+14 -14
View File
@@ -1,14 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ESX MULTICHARACTER</title>
<script type="module" crossorigin src="./assets/index-DGfzXZP_.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-Cy_cJ0Pf.css">
</head>
<body>
<div id="root"></div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ESX MULTICHARACTER</title>
<script type="module" crossorigin src="./assets/index-DejQJnIG.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-Kwy28xkx.css">
</head>
<body>
<div id="root"></div>
</body>
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -1,7 +1,8 @@
import CharacterSelection from './components/CharacterSelection';
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { useNuiEvent } from './utils/useNuiEvent'
import { Character, Locale } from './types/Character';
import { fetchNui } from './utils/fetchNui';
function App() {
const [isVisible, setIsVisible] = useState<boolean>(false);
@@ -10,6 +11,9 @@ function App() {
const [MaxAllowedSlot, setMaxAllowedSlot] = useState<number>(0);
const [locale, setLocale] = useState<Locale>({ char_info_title: '', play: '', title: '' });
useEffect(() => {
fetchNui('nuiReady')
}, [])
useNuiEvent('ToggleMulticharacter', (data:any) => {
if (data.show) {