203 lines
5.8 KiB
Lua
203 lines
5.8 KiB
Lua
--- Desencrypted By PrejuicioX
|
|
|
|
-- =============================================================================
|
|
-- OUTFIT MANAGEMENT SYSTEM
|
|
-- Handles player character outfit data retrieval, application, and preview
|
|
-- =============================================================================
|
|
|
|
-- Retrieves current outfit data for the player character
|
|
function GetCurrentOutfitData()
|
|
local outfitData = {
|
|
drawable = {},
|
|
props = {}
|
|
}
|
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
-- Collect drawable component data (clothing/body parts)
|
|
for componentKey, componentId in pairs(DRAWABLE) do
|
|
outfitData.drawable[componentKey] = {
|
|
drawable = GetPedDrawableVariation(playerPed, componentId),
|
|
texture = GetPedTextureVariation(playerPed, componentId),
|
|
palette = GetPedPaletteVariation(playerPed, componentId)
|
|
}
|
|
end
|
|
|
|
-- Collect prop data (accessories like hats, glasses)
|
|
for propKey, propId in pairs(PROPS) do
|
|
outfitData.props[propKey] = {
|
|
prop = GetPedPropIndex(playerPed, propId),
|
|
texture = GetPedPropTextureIndex(playerPed, propId)
|
|
}
|
|
end
|
|
|
|
return outfitData
|
|
end
|
|
|
|
-- Applies outfit to player with optional animation
|
|
-- portion: "full", "top", "bottom", or "head"
|
|
-- outfitData: table containing drawable and props data
|
|
function ApplyOutfit(outfitData, portion, callbackData)
|
|
Citizen.CreateThread(function()
|
|
CHANGING_OUTFIT = true
|
|
|
|
if portion == "full" then
|
|
ApplyPortion(outfitData, "bottom")
|
|
ApplyPortion(outfitData, "top")
|
|
ApplyPortion(outfitData, "head")
|
|
else
|
|
ApplyPortion(outfitData, portion)
|
|
end
|
|
|
|
CHANGING_OUTFIT = false
|
|
OnPlayerApplyOutfit(outfitData, callbackData)
|
|
|
|
-- Play bag animation if enabled in config
|
|
if Config.bagAnimation.enabled then
|
|
PlayAnim(Config.bagAnimation.dict, Config.bagAnimation.anim, 1)
|
|
end
|
|
|
|
return outfitData
|
|
end)
|
|
end
|
|
|
|
-- Applies outfit for preview (used in wardrobe/shop UI)
|
|
function ApplyPreviewOutfit(outfitData, previewPed)
|
|
Citizen.CreateThread(function()
|
|
-- Clear specific props before applying outfit
|
|
ClearPedProp(previewPed, 2) -- Ears
|
|
ClearPedProp(previewPed, 0) -- Hats
|
|
SetPedPropIndex(previewPed, 1, -1, 0, 0) -- Glasses
|
|
|
|
-- Apply all drawable components
|
|
for componentKey, componentData in pairs(outfitData.drawable) do
|
|
local componentId = DRAWABLE[componentKey]
|
|
SetPedComponentVariation(
|
|
previewPed,
|
|
componentId,
|
|
componentData.drawable,
|
|
componentData.texture,
|
|
componentData.palette
|
|
)
|
|
end
|
|
|
|
-- Apply all props
|
|
for propKey, propData in pairs(outfitData.props) do
|
|
local propId = PROPS[propKey]
|
|
SetPedPropIndex(
|
|
previewPed,
|
|
propId,
|
|
propData.prop,
|
|
propData.texture,
|
|
true
|
|
)
|
|
end
|
|
|
|
return outfitData
|
|
end)
|
|
end
|
|
|
|
-- Applies specific portion of outfit with undress/dress animation
|
|
function ApplyPortion(outfitData, portion)
|
|
local playerPed = PlayerPedId()
|
|
|
|
-- Perform undressing animation and get animation duration
|
|
local animationDuration = PerformAnimation(portion)
|
|
|
|
-- Wait for half the animation to play
|
|
Citizen.Wait(animationDuration / 2)
|
|
|
|
-- Strip down to naked state for the specified portion
|
|
GoNaked(portion)
|
|
|
|
-- Wait for second half of animation
|
|
Citizen.Wait(animationDuration / 2)
|
|
|
|
-- Get which parts should be applied for this portion
|
|
local partsToApply = GetParts(portion)
|
|
|
|
-- Apply drawable components that belong to this portion
|
|
for componentKey, componentData in pairs(outfitData.drawable) do
|
|
local componentId = DRAWABLE[componentKey]
|
|
if partsToApply[componentId] then
|
|
SetPedComponentVariation(
|
|
playerPed,
|
|
componentId,
|
|
componentData.drawable,
|
|
componentData.texture,
|
|
componentData.palette
|
|
)
|
|
end
|
|
end
|
|
|
|
-- Apply props that belong to this portion
|
|
for propKey, propData in pairs(outfitData.props) do
|
|
local propId = PROPS[propKey]
|
|
if partsToApply[propId] then
|
|
SetPedPropIndex(
|
|
playerPed,
|
|
propId,
|
|
propData.prop,
|
|
propData.texture,
|
|
true
|
|
)
|
|
end
|
|
end
|
|
|
|
Citizen.Wait(500)
|
|
ClearPedTasks(playerPed)
|
|
end
|
|
|
|
-- Returns table of component/prop IDs that belong to specified portion
|
|
function GetParts(portion)
|
|
local playerPed = PlayerPedId()
|
|
local partsTable = {}
|
|
local modelHash = GetEntityModel(playerPed)
|
|
|
|
-- Get naked configuration for this model and portion
|
|
local nakedParts = NAKED[modelHash][portion]
|
|
|
|
for partKey, _ in pairs(nakedParts) do
|
|
local drawableId = DRAWABLE[partKey]
|
|
if drawableId then
|
|
partsTable[drawableId] = true
|
|
else
|
|
local propId = PROPS[partKey]
|
|
if propId then
|
|
partsTable[propId] = true
|
|
end
|
|
end
|
|
end
|
|
|
|
return partsTable
|
|
end
|
|
|
|
-- Strips player character to naked state for specified portion
|
|
function GoNaked(portion)
|
|
local playerPed = PlayerPedId()
|
|
|
|
-- Special handling for head portion
|
|
if portion == "head" then
|
|
ClearPedProp(playerPed, 2) -- Ears
|
|
ClearPedProp(playerPed, 0) -- Hats
|
|
SetPedPropIndex(playerPed, 1, -1, 0, 0) -- Glasses
|
|
end
|
|
|
|
local modelHash = GetEntityModel(playerPed)
|
|
local nakedParts = NAKED[modelHash][portion]
|
|
|
|
-- Apply naked values for each part
|
|
for partKey, nakedValue in pairs(nakedParts) do
|
|
local drawableId = DRAWABLE[partKey]
|
|
if drawableId then
|
|
SetPedComponentVariation(playerPed, drawableId, nakedValue, 0, 0)
|
|
else
|
|
local propId = PROPS[partKey]
|
|
if propId then
|
|
SetPedPropIndex(playerPed, propId, nakedValue, 0, true)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--- Desencrypted By PrejuicioX |