diff --git a/client/framework/esx/compatibility.lua b/client/framework/esx/compatibility.lua index 5aaf58a..d86710c 100644 --- a/client/framework/esx/compatibility.lua +++ b/client/framework/esx/compatibility.lua @@ -29,7 +29,8 @@ RegisterNetEvent("skinchanger:getSkin", function(cb) end) end) -RegisterNetEvent("skinchanger:loadSkin", function(skin, cb) + +local function LoadSkin(skin, cb) if skin.model then client.setPlayerAppearance(skin) else -- add validation invisible when failed registration (maybe server restarted when apply skin) @@ -42,16 +43,47 @@ RegisterNetEvent("skinchanger:loadSkin", function(skin, cb) if cb ~= nil then cb() end +end + +RegisterNetEvent("skinchanger:loadSkin", function(skin, cb) + LoadSkin(skin, cb) end) -RegisterNetEvent("skinchanger:loadClothes", function(_, clothes) +local function loadClothes(_, clothes) local components = Framework.ConvertComponents(clothes, client.getPedComponents(cache.ped)) local props = Framework.ConvertProps(clothes, client.getPedProps(cache.ped)) client.setPedComponents(cache.ped, components) client.setPedProps(cache.ped, props) +end + +RegisterNetEvent("skinchanger:loadClothes", function(_, clothes) + loadClothes(_, clothes) end) RegisterNetEvent("esx_skin:openSaveableMenu", function(onSubmit, onCancel) InitializeCharacter(Framework.GetGender(true), onSubmit, onCancel) end) + +local function exportHandler(exportName, func) + AddEventHandler(('__cfx_export_skinchanger_%s'):format(exportName), function(setCB) + setCB(func) + end) +end + +exportHandler("GetSkin", function() + while not Framework.PlayerData do + Wait(1000) + end + + local appearance = lib.callback.await("illenium-appearance:server:getAppearance", false) + return appearance +end) + +exportHandler("LoadSkin", function(skin) + return LoadSkin(skin) +end) + +exportHandler("LoadClothes", function(playerSkin, clothesSkin) + return loadClothes(playerSkin, clothesSkin) +end)