mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Merge pull request #1661 from Zykem/feat/nuiready-await
fix(esx_multicharacter): Await nuiReady before setting up characters
This commit is contained in:
@@ -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
+10
-10
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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>
|
||||
|
||||
+4037
File diff suppressed because it is too large
Load Diff
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user