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)
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.
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?
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)
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?
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…
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 ?