Fix identity not showing up to wait NUI until ready

This commit is contained in:
Bagus Gandhi
2022-02-12 15:59:25 +07:00
parent 8dd3abd872
commit 9ae99f1dde
2 changed files with 11 additions and 6 deletions
+9 -6
View File
@@ -1,4 +1,5 @@
local loadingScreenFinished = false
local ready = false
RegisterNetEvent('esx_identity:alreadyRegistered')
AddEventHandler('esx_identity:alreadyRegistered', function()
@@ -13,18 +14,20 @@ AddEventHandler('esx:loadingScreenOff', function()
loadingScreenFinished = true
end)
RegisterNUICallback('ready', function(data, cb)
ready = true
cb(1)
end)
if not Config.UseDeferrals then
local guiEnabled = false
function EnableGui(state)
SetNuiFocus(state, state)
guiEnabled = state
--[[ CreateThread(function()
while true do
Wait(20000) -- UNCOMMENT THIS METHOD IF YOU ARE EXPERIENCING ISSUES WITH THE UI ON LOCALHOST | IF YOU STILL EXPERIENCE ISSUES AFTER REMOVING COMMENTS, INCREASE THE TIME.
end
end)
]]--
while not ready do
Citizen.Wait(500)
end
SendNUIMessage({
type = "enableui",
enable = state
+2
View File
@@ -1,4 +1,6 @@
$(function() {
$.post('http://esx_identity/ready', JSON.stringify({}));
window.addEventListener('message', function(event) {
if (event.data.type == "enableui") {
document.body.style.display = event.data.enable ? "block" : "none";