Cleanup and placeable_object replacement

Added cleaned up and improved functionality for placeable object.
Example is in unit tests.

Cleanup whitespace and removed accessibility as not used/not documented and doesnt appear to be useful with our current work flow
This commit is contained in:
gononono64 committed 2025-06-04 15:29:21 -05:00
1 parent b5dd8c018c
commit 3fa933fab1
24 files changed
+698 -903

No files matched your search

+13 -13
View File
@@ -11,28 +11,28 @@ ESX = ESX or exports['es_extended']:getSharedObject()
--- @return table|nil The player's full appearance data or nil if not found
function Clothing.GetFullAppearanceData(src)
src = src and tonumber(src)
assert(src, "src is nil")
assert(src, "src is nil")
local Player = ESX.GetPlayerFromId(src)
if not Player then return end
local citId = Player.identifier
if not citId then return end
if Clothing.Players[citId] then return Clothing.Players[citId] end
local result = MySQL.query.await('SELECT skin FROM users WHERE identifier = ?', { citId})
if result[1] == nil then return end
local model = GetEntityModel(GetPlayerPed(src))
local skinData = json.decode(result[1].skin)
local converted = Clothing.ConvertToDefault(skinData)
-- Store complete data in the cache
Clothing.Players[citId] = {
model = model,
skin = skinData,
converted = converted
skin = skinData,
converted = converted
}
return Clothing.Players[citId]
end
@@ -81,16 +81,16 @@ function Clothing.SetAppearance(src, data, updateBackup, save)
local model = GetEntityModel(GetPlayerPed(src))
if not model then return end
local converted = Clothing.ConvertFromDefault(data)
-- Get full appearance data
local currentClothing = Clothing.GetFullAppearanceData(src)
if not currentClothing then return end
local currentSkin = currentClothing.skin
for k, v in pairs(converted) do
currentSkin[k] = v
end
if not Clothing.Players[citId].backup or updateBackup then
Clothing.Players[citId].backup = currentClothing.converted
@@ -100,7 +100,7 @@ function Clothing.SetAppearance(src, data, updateBackup, save)
Clothing.Players[citId].skin = currentSkin
Clothing.Players[citId].model = model
Clothing.Players[citId].converted = Clothing.ConvertToDefault(currentSkin)
if save then
if save then
local encodedSkin = json.encode(currentSkin)
-- saving 1 sql call by adding the query here instead of calling save
MySQL.update.await('UPDATE users SET skin = ? WHERE identifier = ?', {
@@ -137,7 +137,7 @@ end
function Clothing.OpenMenu(src)
src = src and tonumber(src)
assert(src, "src is nil")
assert(src, "src is nil")
TriggerClientEvent('esx_skin:openMenu', src)
end
+44 -18
View File
@@ -11,28 +11,28 @@ QBCore = QBCore or exports['qb-core']:GetCoreObject()
--- @return table|nil The player's full appearance data or nil if not found
function Clothing.GetFullAppearanceData(src)
src = src and tonumber(src)
assert(src, "src is nil")
assert(src, "src is nil")
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local citId = Player.PlayerData.citizenid
if not citId then return end
if Clothing.Players[citId] then return Clothing.Players[citId] end
local result = MySQL.query.await('SELECT * FROM playerskins WHERE citizenid = ? AND active = ?', { citId, 1 })
if result[1] == nil then return end
local model = Player.PlayerData.model
local skinData = json.decode(result[1].skin)
local converted = Clothing.ConvertToDefault(skinData)
-- Store complete data in the cache
Clothing.Players[citId] = {
model = model,
skin = skinData,
converted = converted
Clothing.Players[citId] = {
model = model,
skin = skinData,
converted = converted
}
return Clothing.Players[citId]
end
@@ -64,16 +64,16 @@ function Clothing.SetAppearance(src, data, updateBackup, save)
local model = GetEntityModel(GetPlayerPed(src))
if not model then return end
local converted = Clothing.ConvertFromDefault(data)
-- Get full appearance data
local currentClothing = Clothing.GetFullAppearanceData(src)
if not currentClothing then return end
local currentSkin = currentClothing.skin
for k, v in pairs(converted) do
currentSkin[k] = v
end
if not Clothing.Players[citId].backup or updateBackup then
Clothing.Players[citId].backup = currentClothing.converted
end
@@ -118,7 +118,7 @@ end
function Clothing.OpenMenu(src)
src = src and tonumber(src)
assert(src, "src is nil")
assert(src, "src is nil")
TriggerClientEvent('qb-clothing:client:openMenu', src)
end
@@ -131,7 +131,7 @@ AddEventHandler('community_bridge:Server:OnPlayerLoaded', function(src)
if not Player then return end
local citId = Player.PlayerData.citizenid
if not citId then return end
-- Use GetFullAppearanceData to cache the complete appearance
Clothing.GetFullAppearanceData(src)
end)
@@ -208,6 +208,32 @@ RegisterCommand('clothing:openmenu', function(source, args, rawCommand)
end, false)
RegisterCommand('clothing:crowley', function(source, args, rawCommand)
local src = source
end, false)
-- RegisterCommand('clothing:crowley', function(source, args, rawCommand)
-- local src = source
-- Clothing.SetAppearance(src, {
-- components = {
-- {drawable = 0, texture = 0, component_id = 0},
-- {drawable = 0, texture = 0, component_id = 1},
-- {drawable = 19, texture = 0, component_id = 2},
-- {drawable = 6, texture = 0, component_id = 3},
-- {drawable = 0, texture = 0, component_id = 4},
-- {drawable = 0, texture = 0, component_id = 5},
-- {drawable = 0, texture = 0, component_id = 6},
-- {drawable = 0, texture = 0, component_id = 7},
-- {drawable = 23, texture = 0, component_id = 8},
-- {drawable = 0, texture = 0, component_id = 9},
-- {drawable = 0, texture = 0, component_id = 10},
-- {drawable = 4, texture = 2, component_id = 11}
-- },
-- props = {
-- {drawable = 27, prop_id = 0, texture = 0},
-- {drawable = 0, prop_id = 1, texture = 0},
-- {drawable = 0, prop_id = 2, texture = 0},
-- {drawable = 0, prop_id = 3, texture = 0},
-- {drawable = 0, prop_id = 4, texture = 0},
-- {drawable = 0, prop_id = 5, texture = 0},
-- -- {drawable = 0, prop_id = 6, texture = 0},
-- -- {drawable = 0, prop_id = 7, texture = 0},
-- }
-- }, false, true)
-- end, false)