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

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 Likes

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.

2 Likes

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?

1 Like

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)
2 Likes

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?

2 Likes

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.

1 Like

I saw five line of Citizen.Wait(0) in the client main.lua, do I need to change each to Citizen.Wait(1000)?

1 Like

Since days if the same shit, do all steps nothing helps… if i took a backup for weeks same problem, maybe its a other problem?

But if I delete all my traces, join like fresh, i can make my skin. if i write in chat /register the register menu ist open and then sthe skinchanger is coming again…

…someone any idea?

1 Like

Hello, sorry to post this post news but still no solution? I tested the Twitter method, an error occurred in the console.

1 Like

Hope this helps anyone who needs it.

Adding Citizen.Wait(2000) after line 25 of client.lua of esx_identity
Example of what it should look like.

RegisterNetEvent('esx_identity:showRegisterIdentity')
AddEventHandler('esx_identity:showRegisterIdentity', function()
	Citizen.Wait(2000)			   
	EnableGui(true)
end)

That should fix the loading to early issue.
Then to fix the skin menu from opening twice and have it open only after identity creation, change this:

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

To this in your client.lua for esx_skin

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

When i changed this, the skin menu doesnt open at all.
I was waiting after i filled in the identity, but nothing happens.

Edit: Fixed. I Removed the Citizen.Wait(10) and in some way it works now.

2 Likes

my problem is that everyone is female sex. how to solve the problem because there is a lot of man in my server

1 Like

image

why do i got this error ?

I added the EventHandler to of idetitycheck to another script to prevent both of them to start at the time when someone new enters my server, but it gave me that error … anyone knows how can i place esx_identity:identityCheck to another script ?

https://i.imgur.com/gDiAw8n.png why am i getting this ?
if someone could help me out please