attempt to clean up clothing start

This commit is contained in:
MrNewb committed 2025-02-06 23:33:31 -05:00
1 parent d230cf1242
commit 78ad6c2932
11 files changed
+106 -155

No files matched your search

+6 -5
View File
@@ -133,10 +133,12 @@ end
Utility.GetEntitySkinData = function(entity)
local skinData = {}
skinData.clothing = {}
for i = 0, 11 do
skinData.clothing[i] = {GetPedDrawableVariation(entity, i), GetPedTextureVariation(entity, i)}
end
for i = 0, 13 do
skinData.props[i] = {GetPedPropIndex(entity, i), GetPedPropTextureIndex(entity, i)}
end
return skinData
end
@@ -144,6 +146,9 @@ Utility.SetEntitySkinData = function(entity, skinData)
for i = 0, 11 do
SetPedComponentVariation(entity, i, skinData.clothing[i][1], skinData.clothing[i][2], 0)
end
for i = 0, 13 do
SetPedPropIndex(entity, i, skinData.props[i][1], skinData.props[i][2], 0)
end
return true
end
@@ -160,10 +165,6 @@ Utility.ReloadSkin = function()
return true
end
Utility.RestoreAppearance = function(data)
return Utility.SetEntitySkinData(cache.ped, data)
end
Utility.HelpText = function(text, duration)
AddTextEntry(text, text)
BeginTextCommandDisplayHelp(text)
+34 -8
View File
@@ -1,23 +1,49 @@
Clothing = Clothing or {}
StoredOldClothing = {}
Clothing.SetAppearance = function(clothingData)
ClothingBackup = {}
Clothing.SetAppearance = function(data)
ClothingBackup = Clothing.GetAppearance()
Utility.SetEntitySkinData(cache.ped, data)
return true
end
Clothing.GetAppearance = function()
local clothing = {}
return clothing
return Utility.GetEntitySkinData(cache.ped)
end
Clothing.RestoreAppearance = function()
Utility.SetEntitySkinData(cache.ped, ClothingBackup)
return true
end
Clothing.ReloadSkin = function()
Utility.SetEntitySkinData(cache.ped, ClothingBackup)
return true
end
end
Clothing.UpdateAppearanceBackup = function(data)
ClothingBackup = data
end
RegisterNetEvent('community_bridge:client:updateClothingBackup', function(skindata)
ClothingBackup = skindata
end)
RegisterNetEvent('community_bridge:client:SetAppearance', function(data)
Clothing.SetAppearance(data)
end)
RegisterNetEvent('community_bridge:client:GetAppearance', function()
Clothing.GetAppearance()
end)
RegisterNetEvent('community_bridge:client:RestoreAppearance', function()
Clothing.RestoreAppearance()
end)
RegisterNetEvent('community_bridge:client:ReloadSkin', function()
Clothing.ReloadSkin()
end)
+23 -8
View File
@@ -1,17 +1,32 @@
Clothing = Clothing or {}
Clothing.SetAppearance = function(src, data)
--wip
end
Clothing.GetAppearance = function(src)
--wip
TriggerClientEvent('community_bridge:client:SetAppearance', src, data)
end
Clothing.RestoreAppearance = function(src)
--wip
TriggerClientEvent('community_bridge:client:RestoreAppearance', src)
end
Clothing.ReloadSkin = function(src)
--wip
end
TriggerClientEvent('community_bridge:client:ReloadSkin', src)
end
RegisterNetEvent('community_bridge:client:SetAppearance', function(data)
Clothing.SetAppearance(data)
end)
RegisterNetEvent('community_bridge:client:GetAppearance', function()
Clothing.GetAppearance()
end)
RegisterNetEvent('community_bridge:client:RestoreAppearance', function()
Clothing.RestoreAppearance()
end)
RegisterNetEvent('community_bridge:client:ReloadSkin', function()
Clothing.ReloadSkin()
end)
-6
View File
@@ -2,12 +2,6 @@ if GetResourceState('esx_skin') ~= 'started' then return end
Clothing = Clothing or {}
StoredOldClothing = {}
RegisterNetEvent('community_bridge:client:updateStoredClothing', function(skindata)
StoredOldClothing = skindata
end)
local clothingData = {
male = {
components = {
-24
View File
@@ -1,24 +0,0 @@
if GetResourceState('esx_skin') ~= 'started' then return end
RegisterNetEvent("esx_skin:save", function(skin)
local src = source
TriggerClientEvent('community_bridge:client:updateStoredClothing', src, skin)
end)
Clothing = Clothing or {}
Clothing.SetAppearance = function(src, data)
--wip
end
Clothing.GetAppearance = function(src)
--wip
end
Clothing.RestoreAppearance = function(src)
--wip
end
Clothing.ReloadSkin = function(src)
--wip
end
+12 -9
View File
@@ -1,17 +1,15 @@
if GetResourceState('fivem-appearance') ~= 'started' then return end
Clothing = Clothing or {}
StoredOldClothing = {}
Clothing.SetAppearance = function(clothingData)
Clothing.SetAppearance = function(data)
local clothing = {}
if GetEntityModel(cache.ped) == `mp_m_freemode_01` then
clothingData = clothingData.male
clothing = data.male
else
clothingData = clothingData.female
clothing = data.female
end
StoredOldClothing = exports['fivem-appearance']:getPedAppearance(cache.ped)
exports['fivem-appearance']:setPedAppearance(cache.ped, clothingData)
ClothingBackup = exports['fivem-appearance']:getPedAppearance(cache.ped)
exports['fivem-appearance']:setPedAppearance(cache.ped, clothing)
return true
end
@@ -20,9 +18,14 @@ Clothing.GetAppearance = function()
end
Clothing.RestoreAppearance = function()
return exports['fivem-appearance']:setPedAppearance(cache.ped, StoredOldClothing)
if not next(ClothingBackup) then
return false
end
exports['fivem-appearance']:setPedAppearance(cache.ped, ClothingBackup)
return true
end
Clothing.ReloadSkin = function()
TriggerEvent("fivem-appearance:client:reloadSkin", true)
return true
end
@@ -1,19 +0,0 @@
if GetResourceState('fivem-appearance') ~= 'started' then return end
Clothing = Clothing or {}
Clothing.SetAppearance = function(src, data)
--wip
end
Clothing.GetAppearance = function(src)
--wip
end
Clothing.RestoreAppearance = function(src)
--wip
end
Clothing.ReloadSkin = function(src)
--wip
end
@@ -1,9 +1,6 @@
if GetResourceState('illenium-appearance') ~= 'started' then return end
Clothing = Clothing or {}
StoredOldClothing = {}
Clothing.SetAppearance = function(clothingData)
local clothing = {}
if GetEntityModel(cache.ped) == `mp_m_freemode_01` then
@@ -15,7 +12,7 @@ Clothing.SetAppearance = function(clothingData)
clothing.props = exports['illenium-appearance']:getPedProps(cache.ped)
Prints.Debug(json.encode(clothingData, {indent = true}))
StoredOldClothing = clothing
ClothingBackup = clothing
exports['illenium-appearance']:setPedComponents(cache.ped, clothingData.components)
exports['illenium-appearance']:setPedProp(cache.ped, clothingData.props)
return true
@@ -35,8 +32,8 @@ Clothing.GetAppearance = function()
end
Clothing.RestoreAppearance = function()
exports['illenium-appearance']:setPedComponents(cache.ped, StoredOldClothing.components)
exports['illenium-appearance']:setPedProp(cache.ped, StoredOldClothing.props)
exports['illenium-appearance']:setPedComponents(cache.ped, ClothingBackup.components)
exports['illenium-appearance']:setPedProp(cache.ped, ClothingBackup.props)
return true
end
@@ -1,19 +0,0 @@
if GetResourceState('illenium-appearance') ~= 'started' then return end
Clothing = Clothing or {}
Clothing.SetAppearance = function(src, data)
--wip
end
Clothing.GetAppearance = function(src)
--wip
end
Clothing.RestoreAppearance = function(src)
--wip
end
Clothing.ReloadSkin = function(src)
--wip
end
+25 -30
View File
@@ -2,20 +2,15 @@ if GetResourceState('qb-clothing') ~= 'started' then return end
Clothing = Clothing or {}
StoredOldClothing = {}
RegisterNetEvent('community_bridge:client:updateStoredClothing', function(skindata)
StoredOldClothing = skindata
end)
Clothing.SetAppearance = function(clothingData)
if GetEntityModel(cache.ped) == `mp_m_freemode_01` then
clothingData = clothingData.male
else
clothingData = clothingData.female
end
Clothing.SetAppearance = function(data)
local clothingData = {}
local repackedTable = {}
StoredOldClothing = Clothing.GetAppearance
if GetEntityModel(cache.ped) == `mp_m_freemode_01` then
clothingData = data.male
else
clothingData = data.female
end
ClothingBackup = Clothing.GetAppearance
local componentMap = {
[1] = 'mask',
[3] = 'arms',
@@ -45,21 +40,21 @@ Clothing.SetAppearance = function(clothingData)
face_id = 'face'
}
for _, data in pairs(clothingData) do
if componentMap[data.component_id] then
repackedTable[componentMap[data.component_id]] = {drawable = data.drawable, texture = data.texture}
elseif propMap[data.prop_id] then
repackedTable[propMap[data.prop_id]] = {drawable = data.drawable, texture = data.texture}
elseif specialMap[data.eye_color_id] then
repackedTable[specialMap[data.eye_color_id]] = {drawable = data.drawable, texture = data.texture}
elseif specialMap[data.moles_id] then
repackedTable[specialMap[data.moles_id]] = {drawable = data.drawable, texture = data.texture}
elseif specialMap[data.ageing_id] then
repackedTable[specialMap[data.ageing_id]] = {drawable = data.drawable, texture = data.texture}
elseif specialMap[data.hair_id] then
repackedTable[specialMap[data.hair_id]] = {drawable = data.drawable, texture = data.texture}
elseif specialMap[data.face_id] then
repackedTable[specialMap[data.face_id]] = {drawable = data.drawable, texture = data.texture}
for _, v in pairs(clothingData) do
if componentMap[v.component_id] then
repackedTable[componentMap[v.component_id]] = {drawable = v.drawable, texture = v.texture}
elseif propMap[v.prop_id] then
repackedTable[propMap[v.prop_id]] = {drawable = v.drawable, texture = v.texture}
elseif specialMap[v.eye_color_id] then
repackedTable[specialMap[v.eye_color_id]] = {drawable = v.drawable, texture = v.texture}
elseif specialMap[v.moles_id] then
repackedTable[specialMap[v.moles_id]] = {drawable = v.drawable, texture = v.texture}
elseif specialMap[v.ageing_id] then
repackedTable[specialMap[v.ageing_id]] = {drawable = v.drawable, texture = v.texture}
elseif specialMap[v.hair_id] then
repackedTable[specialMap[v.hair_id]] = {drawable = v.drawable, texture = v.texture}
elseif specialMap[v.face_id] then
repackedTable[specialMap[v.face_id]] = {drawable = v.drawable, texture = v.texture}
end
end
TriggerEvent('qb-clothing:client:loadOutfit', repackedTable)
@@ -67,12 +62,12 @@ Clothing.SetAppearance = function(clothingData)
end
Clothing.GetAppearance = function()
StoredOldClothing = Utility.GetEntitySkinData(cache.ped)
ClothingBackup = Utility.GetEntitySkinData(cache.ped)
return Utility.GetEntitySkinData(cache.ped)
end
Clothing.RestoreAppearance = function()
return Utility.SetEntitySkinData(cache.ped, StoredOldClothing)
return Utility.SetEntitySkinData(cache.ped, ClothingBackup)
end
Clothing.ReloadSkin = function()
+3 -21
View File
@@ -2,25 +2,7 @@ if GetResourceState('qb-clothing') ~= 'started' then return end
RegisterNetEvent('qb-clothing:saveSkin', function(model, skin)
local src = source
if model ~= nil and skin ~= nil then
TriggerClientEvent('community_bridge:client:updateStoredClothing', src, skin)
if model and skin then
TriggerClientEvent('community_bridge:client:updateClothingBackup', src, skin)
end
end)
Clothing = Clothing or {}
Clothing.SetAppearance = function(src, data)
--wip
end
Clothing.GetAppearance = function(src)
--wip
end
Clothing.RestoreAppearance = function(src)
--wip
end
Clothing.ReloadSkin = function(src)
--wip
end
end)