Skip to content

Commit

Permalink
feat(client/framework/esx): ESX 1.11 support (#467)
Browse files Browse the repository at this point in the history
Adds exports from ESX 1.11
  • Loading branch information
Mycroft-Studios authored Nov 13, 2024
1 parent 0f1eb8f commit 1b003ec
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions client/framework/esx/compatibility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

0 comments on commit 1b003ec

Please sign in to comment.