[ESX_IDENTITY] esx_skinchange shows up before (and during) esx_identity registration

esx

#1

How come the esx_skin:openSaveableMenu comes at the same time (or maybe even before) the setIndetity event is triggered? According to this code it shouldn’t, right?

RegisterNUICallback('register', function(data, cb)

  myIdentity = data
  
  if myIdentity.firstname ~= '' and myIdentity.lastname ~= '' and myIdentity.sex ~= '' and myIdentity.dateofbirth ~= '' and myIdentity.height ~= '' then
  
    TriggerServerEvent('esx_identity:setIdentity', data, myIdentifiers)
    
    EnableGui(false)
    
    Wait (500)
    
    TriggerEvent('esx_skin:openSaveableMenu', myIdentifiers.id)
    
  else
  
    TriggerEvent("chatMessage", "^1[identity]", {255, 255, 0}, "fill all info.")
    
  end
  
end)

#2

The problem here is that TriggerServerEvent('esx_identity:setIdentity', data, myIdentifiers) will finish instantly (since events doesn’t block the current thread it’s in).

You would need some kind of flag to cause the thread to wait until the identity has been set properly.


#3

How exactly does a flag work? Is it somewhat like a bool function that tells whether or not e.g registrationIsDone = false or true? If true, continue, if false stay?


#4

Something like that, yes.
I looked at the esx_identity:setIdentity in esx_identity and the problem there is that there is really no way to know when the identity is actually set.

I’m not fond of changing scripts made by others, but in this case I would add a line to the server event handler of setIdentity: TriggerClientEvent("esx_identity:identitySet", source).

I would then split up the code you provided into two parts:

local inRegister = false --Variable to make sure that WE are calling the setIdentity function, not some other script.
RegisterNUICallback('register', function(data, cb)

  myIdentity = data
  
  if myIdentity.firstname ~= '' and myIdentity.lastname ~= '' and myIdentity.sex ~= '' and myIdentity.dateofbirth ~= '' and myIdentity.height ~= '' then
  
    inRegister = true
    TriggerServerEvent('esx_identity:setIdentity', data, myIdentifiers)
    
  else
  
    TriggerEvent("chatMessage", "^1[identity]", {255, 255, 0}, "fill all info.")
    
  end
  
end)
RegisterNetEvent("esx_identity:identitySet") --This event is triggered from within the setIdentity server event handler.
AddEventHandler("esx_identity:identitySet", function() 
    if inRegister then
        inRegister = false
        EnableGui(false)
    
        Wait (500)
    
        TriggerEvent('esx_skin:openSaveableMenu', myIdentifiers.id)
    end
end)

#5

I’m having a similar problem, when a first spawn signs in, the identity registration box appears first and the mouse is rendered useless, the only work around I’ve found so far is to do /register, it resets the registration script and the mouse works again… any ideas of how to fix it?


#6

I am having this issue as well did anyone have a fix for this? I have updated all identity, skin, and essential mode to latest and still not working.


#7

I fixed this issue by changing

Citizen.Wait(500)

TO

Citizen.Wait(1000)

in the client main.lua


Also if you use esx_skin i changed this so that it does not load the skin menu until after your done creating your players identity.

if skin == nil then
TriggerEvent(‘skinchanger:loadSkin’, {sex = 0}, OpenSaveableMenu)
else
TriggerEvent(‘skinchanger:loadSkin’, skin)
end

TO

if skin == nil then
Citizen.Wait(10)
TriggerEvent(‘skinchanger:loadSkin’, {sex = 0})
else
TriggerEvent(‘skinchanger:loadSkin’, skin)
end