2025-06-07 22:50:13 -04:00
|
|
|
---@diagnostic disable: duplicate-set-field
|
2025-05-24 18:03:31 -05:00
|
|
|
if GetResourceState('esx_skin') == 'missing' then return end
|
2025-07-11 15:23:24 -04:00
|
|
|
if GetResourceState('rcore_clothing') ~= 'missing' then return end
|
2025-05-24 18:03:31 -05:00
|
|
|
|
|
|
|
|
Clothing = Clothing or {}
|
|
|
|
|
|
|
|
|
|
Components = {}
|
|
|
|
|
Components.Map = {
|
|
|
|
|
[1] = 'mask', -- componentId
|
|
|
|
|
[2] = 'ears',
|
|
|
|
|
[3] = 'arms',
|
|
|
|
|
[4] = 'pants',
|
|
|
|
|
[5] = 'bags',
|
|
|
|
|
[6] = 'shoes',
|
|
|
|
|
[7] = 'chain',
|
|
|
|
|
[8] = 'tshirt',
|
|
|
|
|
[9] = 'bproof',
|
|
|
|
|
[10] = 'decals',
|
|
|
|
|
[11] = 'torso'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Components.InverseMap = {
|
|
|
|
|
mask = 1, -- componentId
|
|
|
|
|
arms = 3,
|
|
|
|
|
pants = 4,
|
|
|
|
|
bags = 5,
|
|
|
|
|
shoes = 6,
|
|
|
|
|
chain = 7,
|
|
|
|
|
tshirt = 8,
|
|
|
|
|
bproof = 9,
|
|
|
|
|
decals = 10,
|
|
|
|
|
torso = 11,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Props = {}
|
|
|
|
|
Props.Map = {
|
|
|
|
|
[0] = 'helmet', -- propId
|
|
|
|
|
[1] = 'glasses',
|
|
|
|
|
[2] = 'ears',
|
|
|
|
|
[6] = 'watches',
|
|
|
|
|
[7] = 'bracelets'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Props.InverseMap = {
|
|
|
|
|
helmet_1 = 0,
|
|
|
|
|
helmet_2 = 0,
|
|
|
|
|
glasses_1 = 1,
|
|
|
|
|
glasses_2 = 1,
|
|
|
|
|
ears_1 = 2,
|
|
|
|
|
ears_2 = 2,
|
|
|
|
|
watches_1 = 6,
|
|
|
|
|
watches_2 = 6,
|
|
|
|
|
bracelets_1 = 7,
|
|
|
|
|
bracelets_2 = 7,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- Converts from illinium format to esx format
|
|
|
|
|
function Components.ConvertFromDefault(defaultComponents)
|
|
|
|
|
local returnComponents = {}
|
2025-07-11 15:23:24 -04:00
|
|
|
for index, componentData in pairs(defaultComponents or {}) do
|
2025-05-24 18:03:31 -05:00
|
|
|
local componentId = Components.Map[componentData.component_id]
|
|
|
|
|
if componentId then
|
|
|
|
|
returnComponents[componentId .. '_1'] = componentData.drawable
|
|
|
|
|
returnComponents[componentId .. '_2'] = componentData.texture
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-07-11 15:23:24 -04:00
|
|
|
return returnComponents
|
|
|
|
|
end
|
2025-05-24 18:03:31 -05:00
|
|
|
|
|
|
|
|
function Components.ConvertToDefault(esxComponents)
|
|
|
|
|
local returnComponents = {}
|
2025-07-11 15:23:24 -04:00
|
|
|
for componentIndex, componentData in pairs(esxComponents or {}) do
|
2025-05-24 18:03:31 -05:00
|
|
|
local isTexture = componentIndex:find('_2')
|
|
|
|
|
componentIndex = componentIndex:gsub('_1', ''):gsub('_2', '')
|
|
|
|
|
local componentId = Components.InverseMap[componentIndex]
|
|
|
|
|
if componentId then
|
|
|
|
|
if isTexture then
|
|
|
|
|
returnComponents[componentId] = returnComponents[componentId] or {}
|
|
|
|
|
returnComponents[componentId].texture = componentData
|
|
|
|
|
else
|
|
|
|
|
returnComponents[componentId] = returnComponents[componentId] or {}
|
|
|
|
|
returnComponents[componentId].component_id = componentId
|
|
|
|
|
returnComponents[componentId].drawable = componentData
|
|
|
|
|
returnComponents[componentId].texture = returnComponents[componentId].texture or 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return returnComponents
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Props.ConvertFromDefault(defaultProps)
|
|
|
|
|
local returnProps = {}
|
2025-06-07 22:50:13 -04:00
|
|
|
for index, propData in pairs(defaultProps or {}) do
|
2025-05-24 18:03:31 -05:00
|
|
|
local propId = Props.Map[propData.prop_id]
|
|
|
|
|
if propId then
|
|
|
|
|
returnProps[propId .. '_1'] = propData.drawable
|
2025-06-07 22:50:13 -04:00
|
|
|
returnProps[propId .. '_2'] = propData.texture
|
2025-05-24 18:03:31 -05:00
|
|
|
end
|
|
|
|
|
end
|
2025-06-07 22:50:13 -04:00
|
|
|
return returnProps
|
2025-05-24 18:03:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Props.ConvertToDefault(esxProps)
|
|
|
|
|
local returnProps = {}
|
2025-07-11 15:23:24 -04:00
|
|
|
for propIndex, propData in pairs(esxProps or {}) do
|
2025-05-24 18:03:31 -05:00
|
|
|
local isTexture = propIndex:find('_2')
|
|
|
|
|
propIndex = propIndex:gsub('_1', ''):gsub('_2', '')
|
|
|
|
|
local propId = Props.InverseMap[propIndex]
|
|
|
|
|
if propId then
|
|
|
|
|
if isTexture then
|
|
|
|
|
returnProps[propId] = returnProps[propId] or {}
|
|
|
|
|
returnProps[propId].texture = propData
|
|
|
|
|
else
|
|
|
|
|
returnProps[propId] = returnProps[propId] or {}
|
|
|
|
|
returnProps[propId].prop_id = propId
|
|
|
|
|
returnProps[propId].drawable = propData
|
2025-06-07 22:50:13 -04:00
|
|
|
returnProps[propId].texture = returnProps[propId].texture or 0
|
2025-05-24 18:03:31 -05:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
table.sort(returnProps, function(a, b)
|
|
|
|
|
return a.prop_id < b.prop_id
|
|
|
|
|
end)
|
|
|
|
|
end
|
2025-06-07 22:50:13 -04:00
|
|
|
return returnProps
|
2025-05-24 18:03:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Clothing.ConvertFromDefault(defaultClothing)
|
|
|
|
|
local components = Components.ConvertFromDefault(defaultClothing.components)
|
|
|
|
|
local props = Props.ConvertFromDefault(defaultClothing.props)
|
|
|
|
|
|
|
|
|
|
for propsIndex, propData in pairs(props) do
|
|
|
|
|
components[propsIndex] = propData
|
2025-06-07 22:50:13 -04:00
|
|
|
end
|
2025-05-24 18:03:31 -05:00
|
|
|
|
|
|
|
|
return components --skin
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Clothing.ConvertToDefault(esxClothing)
|
|
|
|
|
local components = Components.ConvertToDefault(esxClothing)
|
|
|
|
|
local props = Props.ConvertToDefault(esxClothing)
|
|
|
|
|
return { components = components, props = props }
|
2025-07-28 01:38:25 -04:00
|
|
|
end
|