From bf9ce2b20d1be0751cedf929cd988560b4b37b1a Mon Sep 17 00:00:00 2001 From: root Date: Wed, 15 Apr 2026 11:10:01 +0200 Subject: [PATCH] Auto-sync 2026-04-15 11:10 --- [char]/codem-appearance/client/editable.lua | 67 ++++----------------- 1 file changed, 13 insertions(+), 54 deletions(-) diff --git a/[char]/codem-appearance/client/editable.lua b/[char]/codem-appearance/client/editable.lua index 8d7a512f..a2058e95 100644 --- a/[char]/codem-appearance/client/editable.lua +++ b/[char]/codem-appearance/client/editable.lua @@ -706,14 +706,17 @@ end) -- NUI: Outfit anziehen (JETZT ANZIEHEN Button) RegisterNUICallback('wearClothing', function(data, cb) if not data or not data.skin then cb({}); return end - local skin = type(data.skin) == 'string' and json.decode(data.skin) or data.skin - if skin then - -- Skin auf den Charakter anwenden - TriggerEvent('codem-appearance:setPlayerSkin', skin) - -- Auch per Export falls verfügbar - if GetResourceState('codem-appearance') == 'started' then - exports['codem-appearance']:SetPlayerSkin(skin) - end + + -- Skin kann als String oder Table ankommen + local skin = data.skin + if type(skin) == 'string' then + local ok, decoded = pcall(json.decode, skin) + if ok and decoded then skin = decoded end + end + + if skin and type(skin) == 'table' then + -- skinchanger:loadSkin ist der Standard-ESX Skin-Loader + TriggerEvent('skinchanger:loadSkin', skin) end cb({}) end) @@ -739,53 +742,9 @@ RegisterNUICallback('CreateClothingCategory', function(data, cb) cb({}) end) --- Skin anwenden (von wearClothing aufgerufen) +-- Skin anwenden via skinchanger (kompatibler mit ESX) RegisterNetEvent('codem-appearance:setPlayerSkin') AddEventHandler('codem-appearance:setPlayerSkin', function(skin) - local ped = PlayerPedId() if not skin then return end - - -- Kleidung anwenden - local components = { - { id = 1, key = 'mask_1', tex = 'mask_2' }, - { id = 3, key = 'arms', tex = 'arms_2' }, - { id = 4, key = 'pants_1', tex = 'pants_2' }, - { id = 5, key = 'parachute_1', tex = 'parachute_2' }, - { id = 6, key = 'shoes_1', tex = 'shoes_2' }, - { id = 7, key = 'accessory_1', tex = 'accessory_2' }, - { id = 8, key = 'undershirt_1', tex = 'undershirt_2' }, - { id = 9, key = 'bproof_1', tex = 'bproof_2' }, - { id = 10, key = 'torso_1', tex = 'torso_2' }, - { id = 11, key = 'tshirt_1', tex = 'tshirt_2' }, - } - - for _, comp in ipairs(components) do - if skin[comp.key] ~= nil then - SetPedComponentVariation(ped, comp.id, - tonumber(skin[comp.key]) or 0, - tonumber(skin[comp.tex] or 0) or 0, - 2) - end - end - - -- Props anwenden - local props = { - { id = 0, key = 'glasses_1', tex = 'glasses_2' }, - { id = 1, key = 'helmet_1', tex = 'helmet_2' }, - { id = 2, key = 'ears_1', tex = 'ears_2' }, - { id = 6, key = 'watches_1', tex = 'watches_2' }, - { id = 7, key = 'bracelets_1', tex = 'bracelets_2' }, - } - - for _, prop in ipairs(props) do - if skin[prop.key] ~= nil then - local val = tonumber(skin[prop.key]) - if val and val >= 0 then - SetPedPropIndex(ped, prop.id, val, - tonumber(skin[prop.tex] or 0) or 0, true) - else - ClearPedProp(ped, prop.id) - end - end - end + TriggerEvent('skinchanger:loadSkin', skin) end)