2025-07-11 15:23:24 -04:00
|
|
|
---@diagnostic disable: duplicate-set-field
|
2025-02-06 22:53:30 -05:00
|
|
|
Clothing = Clothing or {}
|
2025-05-24 18:03:31 -05:00
|
|
|
Clothing.LastAppearance = Clothing.LastAppearance or {}
|
2025-08-21 00:09:54 -05:00
|
|
|
Callback = Callback or Require("lib/callback/shared/callback.lua")
|
2025-05-24 18:03:31 -05:00
|
|
|
|
2025-09-10 12:27:12 -04:00
|
|
|
---This will get the name of the in use resource.
|
|
|
|
|
---@return string
|
|
|
|
|
Clothing.GetResourceName = function()
|
|
|
|
|
return 'default'
|
|
|
|
|
end
|
|
|
|
|
|
2025-12-23 19:27:27 -05:00
|
|
|
---This will check if the player model if male/female
|
|
|
|
|
---@param src number
|
|
|
|
|
---@return boolean
|
|
|
|
|
function Clothing.IsMale(src)
|
|
|
|
|
local ped = GetPlayerPed(src)
|
|
|
|
|
if not ped or not DoesEntityExist(ped) then return false end
|
|
|
|
|
return GetEntityModel(ped) == `mp_m_freemode_01`
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
---Get the skin data of a player
|
|
|
|
|
---@param src number
|
|
|
|
|
---@return table
|
2025-05-24 18:03:31 -05:00
|
|
|
function Clothing.GetAppearance(src)
|
|
|
|
|
return Callback.Trigger('community_bridge:cb:GetAppearance', src)
|
|
|
|
|
end
|
2025-02-06 22:53:30 -05:00
|
|
|
|
2025-12-23 19:27:27 -05:00
|
|
|
---Apply skin data to a player
|
|
|
|
|
---@param src number
|
|
|
|
|
---@param data table
|
|
|
|
|
function Clothing.SetAppearance(src, data)
|
2025-05-24 18:03:31 -05:00
|
|
|
local strSrc = tostring(src)
|
|
|
|
|
Clothing.LastAppearance[strSrc] = Clothing.GetAppearance(src)
|
2025-02-06 23:33:31 -05:00
|
|
|
TriggerClientEvent('community_bridge:client:SetAppearance', src, data)
|
2025-02-06 22:53:30 -05:00
|
|
|
end
|
|
|
|
|
|
2025-05-24 18:03:31 -05:00
|
|
|
--- Sets a player's appearance based on gender-specific data
|
2025-06-07 22:50:13 -04:00
|
|
|
---@param src number The server ID of the player
|
|
|
|
|
---@param data table Table containing separate appearance data for male and female characters
|
|
|
|
|
---@return table|nil Appearance updated player appearance data or nil if failed
|
2025-05-24 18:03:31 -05:00
|
|
|
function Clothing.SetAppearanceExt(src, data)
|
|
|
|
|
local tbl = Clothing.IsMale(src) and data.male or data.female
|
|
|
|
|
Clothing.SetAppearance(src, tbl)
|
2025-02-06 22:53:30 -05:00
|
|
|
end
|
|
|
|
|
|
2025-12-23 19:27:27 -05:00
|
|
|
---Restore the last saved appearance of a player
|
|
|
|
|
---@param src number
|
|
|
|
|
function Clothing.RestoreAppearance(src)
|
2025-05-24 18:03:31 -05:00
|
|
|
TriggerClientEvent('community_bridge:client:RestoreAppearance', src)
|
2025-02-06 23:33:31 -05:00
|
|
|
end
|
|
|
|
|
|
2025-12-23 19:27:27 -05:00
|
|
|
return Clothing
|