PainedPsyche / cui_character

An advanced character and clothes editor for esx framework that aims to be comfortable to use, hide complexity and blend in with original GTA V interface elements.
73 stars 48 forks source link

Error when trying to update clothes #34

Open Richards0nd opened 3 years ago

Richards0nd commented 3 years ago

I have a problem, and I can't solve it ....

I have a code on my server, which, if any player wears a vest, it automatically adds to the player, the vest (clothing), so that it is visually more realistic ...

However, after I added your script, it kind of stopped working properly. Whenever I wear the vest item, it changes all my clothes, it also changes my gender ... I've tried several options, but I can't fix it. I tried other ways to change the player's outfit, but also without success.

My original code (Before adding this script):

TriggerEvent('skinchanger:getSkin', function(skin)
    if skin.sex == 0 then
        TriggerEvent('skinchanger:loadClothes', skin, {['bproof_1'] = 4,  ['bproof_2'] = 0})
        TriggerEvent('gcn_skin:setLastSkin', skin)
    else
        TriggerEvent('skinchanger:loadClothes', skin, {['bproof_1'] = 13,  ['bproof_2'] = 1})
        TriggerEvent('gcn_skin:setLastSkin', skin)
    end
end)

-- First attempt to try to make the code work

TriggerEvent('skinchanger:getSkin', function(skin)
    if skin.sex == 0 then
        TriggerEvent('skinchanger:loadClothes', skin, {['bproof_1'] = 4,  ['bproof_2'] = 0})
    else
        TriggerEvent('skinchanger:loadClothes', skin, {['bproof_1'] = 13,  ['bproof_2'] = 1})
    end
end)

-- Second attempt

ESX.TriggerServerCallback('gcn_skin:getPlayerSkin', function(skin)
    if skin.sex == 0 then
        TriggerEvent('skinchanger:change', "bproof_1", 4)
        TriggerEvent('skinchanger:change', "bproof_2", 0)
    else
        TriggerEvent('skinchanger:change', "bproof_1", 13)
        TriggerEvent('skinchanger:change', "bproof_2", 1)
    end
end)

-- Third attempt

ESX.TriggerServerCallback('gcn_skin:getPlayerSkin', function(skin)
    if skin.sex == 0 then
        TriggerEvent('skinchanger:loadClothes', skin, {['bproof_1'] = 4, ['bproof_2'] = 0})
    else
        TriggerEvent('skinchanger:loadClothes', skin, {['bproof_1'] = 13, ['bproof_2'] = 1})
    end
end)

-- Fourth attempt

TriggerEvent('skinchanger:getSkin', function(skin)
    if skin.sex == 0 then
        TriggerEvent('skinchanger:change', "bproof_1", 4)
        TriggerEvent('skinchanger:change', "bproof_2", 0)
    else
        TriggerEvent('skinchanger:change', "bproof_1", 13)
        TriggerEvent('skinchanger:change', "bproof_2", 1)
    end
end)

And another thing ... When I try to put / remove the vest, directly in the police menu (esx_police), it also gets the bug ...

I recorded a video, showing all the problems I encountered. https://youtu.be/saPma1s_4Pw

So, I did another test, only this time, I removed it, deleted the name of the skinchanger folder, and left another name. The bugs were minor ... Only when I put the clothes on to remove / add the vest that it totally changed to, otherwise ... it was working perfectly. https://youtu.be/Br7bqRc5cU8

PainedPsyche commented 3 years ago

You cannot have skinchanger enabled in your server.cfg or it will corrupt the data that cui_character uses, also you should not use skinchanger:loadClothes or skinchanger:change. I only implemented them so the job scripts don't completely break.

Instead use cui_character:updateClothes event. Look up the definition in client/main.lua.

You need to remember that the data passed requires full character data not just the parts you changed (bproof) since they are all stored in one SQL column, so entire character needs to be updated whenever any clothing part changes.

What happens is that when you only pass the bproof, the rest of the table is filled with nil values and your character is overwritten with corrupted data.

Richards0nd commented 3 years ago

You cannot have skinchanger enabled in your server.cfg or it will corrupt the data that cui_character uses, also you should not use skinchanger:loadClothes or skinchanger:change. I only implemented them so the job scripts don't completely break.

Instead use cui_character:updateClothes event. Look up the definition in client/main.lua.

You need to remember that the data passed requires full character data not just the parts you changed (bproof) since they are all stored in one SQL column, so entire character needs to be updated whenever any clothing part changes.

What happens is that when you only pass the bproof, the rest of the table is filled with nil values and your character is overwritten with corrupted data.

I understood... Thank you for your help!

But I had only one doubt left ... In the case of the police job, when the player is going to add only the vest, what should I do? Because for example:

Example in the video (I completely removed the skinchanger to have no problem): https://youtu.be/YvHfBNYIZMo

When I recorded it, I ended up encountering another problem ... If I activate one of the clothes in the menu, and then use another one without removing the current one, it bugs everything ... In the video is showing the problem ...

PainedPsyche commented 3 years ago

If I just take the vest from the clothing menu, it will set all my standard clothes back ... Instead of just putting on the vest, which is correct ... Because if I have a work outfit on, and add the vest, it will replace all the work clothes, and put the player’s original clothes with the vest.

Then snapshot the work clothes somewhere and pass them to cui_character:updateClothes instead of the standard.

If I activate one of the clothes in the menu, and then use another one without removing the current one, it bugs everything ... In the video is showing the problem ...

It's probably the same thing, something in that script still uses old skinchanger methods, find them and replace them.

shruog commented 3 years ago

Você conseguiu arrumar o erro, tenho mesmo problema com uniformes e com esx_np_skinshop_v2 mesmo erro eles usam skinchanger eu consegui uma hora desabilitar o skinchanger em jogo e tudo funcionou uniformes etc.. mas da erro de novo não entendo porque esse script substitui o skinchanger e o esx_skin

maxcamorra commented 3 years ago

So change all skinchanger:loadClothes to cui_character:updateClothes?

Richards0nd commented 3 years ago

If I just take the vest from the clothing menu, it will set all my standard clothes back ... Instead of just putting on the vest, which is correct ... Because if I have a work outfit on, and add the vest, it will replace all the work clothes, and put the player’s original clothes with the vest.

Then snapshot the work clothes somewhere and pass them to cui_character:updateClothes instead of the standard.

If I activate one of the clothes in the menu, and then use another one without removing the current one, it bugs everything ... In the video is showing the problem ...

It's probably the same thing, something in that script still uses old skinchanger methods, find them and replace them.

I tried to change the correct events, as you had informed, but it doesn't even work ...

I changed what I had: skinchanger:loadClothes for: cui_character:updateClothes https://youtu.be/T1Ri2QHPzP4

Except as you can see in the video, it doesn't work. What should I do for sure? Because I'm 2 days trying to understand how the system works, to use it correctly, but I couldn't.

Richards0nd commented 3 years ago

Você conseguiu arrumar o erro, tenho mesmo problema com uniformes e com esx_np_skinshop_v2 mesmo erro eles usam skinchanger eu consegui uma hora desabilitar o skinchanger em jogo e tudo funcionou uniformes etc.. mas da erro de novo não entendo porque esse script substitui o skinchanger e o esx_skin

Até o momento não consegui corrigir... Você tem que remover por completo o script skinchanger, deixar apenas o cui_character e o esx_skin. Para que funcione grande parte dos recursos...