Files
community_bridge/modules/clothing/_default/server.lua
T

52 lines
1.7 KiB
Lua
Raw Normal View History

2025-07-11 15:23:24 -04:00
---@diagnostic disable: duplicate-set-field
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
---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
---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)
end
2025-05-24 18:03:31 -05:00
--- Sets a player's appearance based on gender-specific data
---@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)
end
---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
return Clothing