Skip to content

Component

Component is a very useful module to manage entity component. The module is designed to create a persistence of component colors if you defined a custom colorway.

JO Variables

Client jo.component.categoryName

Type : table

Links between the hash and name of a category.

key: category hash
value: category name

Client jo.component.order

Type : table

The order to apply the component

key: order to apply the component
value: category name

Client jo.component.wearableStates

Type : table

The list of available wearable state by category

key: category name
value: table of wearable states

JO Functions

Client jo.component.apply()

A function to apply a component on the ped

Syntax

lua
jo.component.apply(ped, category, _data)

Parameters

ped : integer

The entity ID

category : string|integer

The component category

_data : table

The component data

_data.hash : integer - The component hash

_data.palette : string|integer - The color palette of the component Optional

_data.tint0 : integer - The first color number Optional

_data.tint1 : integer - The second color number Optional

_data.tint2 : integer - The third color number Optional

_data.drawable : integer - The drawable value Optional

_data.albedo : integer - The albedo value Optional

_data.normal : integer - The normal value Optional

_data.material : integer - The material value Optional

Example

lua
local ped = PlayerPedId()
local category = "hats"
local data = { hash = "CLOTHING_ITEM_F_HAT_241_PANTHER_VAR_001" }
jo.component.apply(ped, category, data)

Client jo.component.applyComponents()

A function to apply multiple components to a ped

Syntax

lua
jo.component.applyComponents(ped, components)

Parameters

ped : integer

The entity ID

components : table

Table of components indexed by category name with component data

Example

lua
local ped = PlayerPedId()
local clothes = {
  hats = { hash = "CLOTHING_ITEM_F_HAT_241_PANTHER_VAR_001" },
  pants = { hash = 0x1234567 }
}
jo.component.applyComponents(ped, clothes)

Client jo.component.applySkin()

A function to apply a complete skin configuration to a ped

Syntax

lua
jo.component.applySkin(ped, skin)

Parameters

ped : integer

The entity ID

skin : table

The skin configuration data

skin.model : string - The model name Optional

skin.headHash : integer - The head component hash Optional

skin.headIndex : integer - The head index for skin tone Optional

skin.skinTone : integer - The skin tone value Optional

skin.bodyUpperHash : integer - The upper body component hash Optional

skin.bodyLowerHash : integer - The lower body component hash Optional

skin.bodiesIndex : integer - The body index for skin tone Optional

skin.bodyType : integer - The body type outfit preset Optional

skin.bodyWeight : integer - The body weight outfit preset Optional

skin.expressions : table - Table of expression values Optional

skin.eyesHash : integer - The eyes component hash Optional

skin.eyesIndex : integer - The eyes index Optional

skin.teethHash : integer - The teeth component hash Optional

skin.teethIndex : integer - The teeth index Optional

skin.hair : table - Hair component data Optional

skin.beards_complete : table - Beard component data Optional

skin.overlays : table - Table of overlay configurations Optional

skin.bodyScale : number - The body scale value Optional

Example

lua
local ped = PlayerPedId()
local skin = {
  model = "mp_male",
  headIndex = 1,
  skinTone = 1,
  bodiesIndex = 1,
}
jo.component.applySkin(ped, skin)

Client jo.component.bootsAreUnderPant()

A function to know if the boots are under the pant

Syntax

lua
jo.component.bootsAreUnderPant(ped)

Parameters

ped : integer

The entity ID

Return Value

Type : boolean

Return true if boots are under the pant, false otherwise.

Example

lua
local ped = PlayerPedId()
local isUnder = jo.component.bootsAreUnderPant(ped)
print(isUnder)

Client jo.component.collarClose()

A function to close the collar

Syntax

lua
jo.component.collarClose(ped, data)

Parameters

ped : integer

The entity ID

data : table

The component data, see the structure in jo.component.apply()

Example

lua
local ped = PlayerPedId()
local data = { hash = "CLOTHING_ITEM_M_SHIRT_209_TINT_005" }
jo.component.collarClose(ped, data)

Client jo.component.collarIsOpened()

Return if the collar is opened

Syntax

lua
jo.component.collarIsOpened(ped)

Parameters

ped : integer

The entity ID

Return Value

Type : boolean

Return true if the collar is opened, false otherwise.

Example

lua
local ped = PlayerPedId()
local isOpened = jo.component.collarIsOpened(ped)
print(isOpened)

Client jo.component.collarOpen()

A function to open the collar

Syntax

lua
jo.component.collarOpen(ped, data)

Parameters

ped : integer

The entity ID

data : table

The component data, see the structure in jo.component.apply()

Example

lua
local ped = PlayerPedId()
local data = { hash = "CLOTHING_ITEM_M_SHIRT_209_TINT_005" }
jo.component.collarOpen(ped, data)

Client jo.component.getBaseLayer()

A function to get the base layer of a component

Syntax

lua
jo.component.getBaseLayer(ped, hash, inTable)

Parameters

ped : integer

The entity ID or the metaped type

hash : string|integer

The component hash

inTable : boolean Optional

true to get the result as a table, false to get the result as separate values
Default: false

Return Value

Type : table|integer,integer,integer,integer,integer,integer,integer,integer

When inTable is true: returns a table with {drawable, albedo, normal, material, palette, tint0, tint1, tint2}
When inTable is false: 1st: drawable
2nd: albedo
3rd: normal
4th: material
5th: palette
6th: tint0
7th: tint1
8th: tint2

Example

lua
local ped = PlayerPedId()
local componentHash = -1108325521
local baseLayer = jo.component.getBaseLayer(ped, componentHash, true)
log(baseLayer)
--expected output: {drawable = -2020229219, albedo = -1921859074, normal = 1163305928, material = 1671174462, palette = 1090645383, tint0 = 44, tint1 =  44, tint2 = 44}
local drawable, albedo, normal, mterial, palette, tint0, tint1, tint2 = jo.component.getBaseLayer(ped, componentHash, false)
print(drawable, albedo, normal, mterial, palette, tint0, tint1, tint2)
--expected output: -2020229219 -1921859074 1163305928 1671174462 1090645383 44 44 44

Client jo.component.getBodiesLowerFromSkinTone()

A function to get the lower body component hash from bodies index and skin tone

Syntax

lua
jo.component.getBodiesLowerFromSkinTone(ped, bodiesIndex, skinTone)

Parameters

ped : integer|string

The entity ID or model name

bodiesIndex : integer Optional

The bodies index, defaults to 1

skinTone : integer Optional

The skin tone, defaults to 1

Return Value

Type : string

The lower body component hash string

Example

lua
local ped = PlayerPedId() -- OR "mp_male"/"mp_female"
local bodiesIndex = 1
local skinTone = 2
local hash = jo.component.getBodiesLowerFromSkinTone(ped, bodiesIndex, skinTone)
print(hash)

Client jo.component.getBodiesUpperFromSkinTone()

A function to get the upper body component hash from bodies index and skin tone

Syntax

lua
jo.component.getBodiesUpperFromSkinTone(ped, bodiesIndex, skinTone)

Parameters

ped : integer|string

The entity ID or model name

bodiesIndex : integer Optional

The bodies index, defaults to 1

skinTone : integer Optional

The skin tone, defaults to 1

Return Value

Type : string

The upper body component hash string

Example

lua
local ped = PlayerPedId() -- OR "mp_male"/"mp_female"
local bodiesIndex = 1
local skinTone = 2
local hash = jo.component.getBodiesUpperFromSkinTone(ped, bodiesIndex, skinTone)
print(hash)

Client jo.component.getCategoriesEquiped()





Return the list of component categories equiped on the ped

Syntax

lua
jo.component.getCategoriesEquiped(ped)

Parameters

ped : integer

The entity ID

Return Value

Type : table

Return an table with the category in key and data in value
categories[x].index : integer - the index of the component on the ped
categories[x].category : string - the category name if the hash is known

Example

lua
local ped = PlayerPedId()
local categories = jo.component.getCategoriesEquiped(ped)
log(categories)
-- Expected output: categories = { 539411565 = {index = 1, category = "shirts_full"}, 491541130 = { index = 2, category = "pants"} }

Client jo.component.getCategoryNameFromHash()

A function to get the category name from a hash value

Syntax

lua
jo.component.getCategoryNameFromHash(category)

Parameters

category : integer|string

The category hash

Return Value

Type : string

The category name, or "unknown" if not found

Example

lua
local hash = 0x9925C067
local category = jo.component.getCategoryNameFromHash(hash)
print(category)
-- Expected output: `hats`

Client jo.component.getCategoryTint()

A function to get the tints of a category

Syntax

lua
jo.component.getCategoryTint(ped, category, inTable)

Parameters

ped : integer

The entity ID

category : string|integer

The category of the component

inTable : boolean

When inTable is true, returns a table with {palette, tint0, tint1, tint2}
When inTable is false, returns four separate values: palette, tint0, tint1, tint2

Return Value

Type : table|integer,integer,integer,integer

When inTable is true: returns a table with {palette, tint0, tint1, tint2}
When inTable is false: 1st: color palette
2nd: tint number 0
3rd: tint number 1
4th: tint number 2

Example

lua
local ped = PlayerPedId()
local category = "shirts_full"
local palette, tint0, tint1, tint2 = jo.component.getCategoryTint(ped, category)
print(palette, tint0, tint1, tint2)

Client jo.component.getComponentCategory()

Return the category hash of a component and if it's a MP component

Syntax

lua
jo.component.getComponentCategory(ped, hash)

Parameters

ped : integer

The entity ID

hash : integer

The component hash

Return Value

Type : integer,boolean

1st: Return hash value of the category
2nd: Return true if it's a MP component, false otherwise

Example

lua
local ped = PlayerPedId()
local hash = "CLOTHING_ITEM_F_HAT_241_PANTHER_VAR_001"
local catHash, isMp = jo.component.getComponentCategory(ped, hash)
print(catHash, isMp)
-- Expected output: -1725579161, true

Client jo.component.getComponentEquiped()

A function to get the hash of the component equiped in a category

Syntax

lua
jo.component.getComponentEquiped(ped, category)

Parameters

ped : integer

The entity ID

category : string|integer

The category to get the component

Return Value

Type : table

Return the component datas

Example

lua
local ped = PlayerPedId()
local category = "hats"
local component = jo.component.getComponentEquiped(ped, category)
print(component)

Client jo.component.getComponentsEquiped()

A function to get all components equiped

Syntax

lua
jo.component.getComponentsEquiped(ped)

Parameters

ped : integer

The entity ID

Return Value

Type : table

Return the list of components equiped

Example

lua
local ped = PlayerPedId()
local components = jo.component.getComponentsEquiped(ped)
log(components)

Client jo.component.getEyesFromIndex()

A function to get the eyes component hash from an index

Syntax

lua
jo.component.getEyesFromIndex(ped, index)

Parameters

ped : integer|string

The entity ID or model name

index : integer Optional

The eyes index, defaults to 1

Return Value

Type : string

The eyes component hash string

Example

lua
local ped = PlayerPedId() -- OR "mp_male"/"mp_female"
local index = 1
local hash = jo.component.getEyesFromIndex(ped, index)
print(hash)

Client jo.component.getHeadFromSkinTone()

A function to get the head component hash from head index and skin tone

Syntax

lua
jo.component.getHeadFromSkinTone(ped, headIndex, skinTone)

Parameters

ped : integer

The entity ID

headIndex : integer Optional

The head index, defaults to 1

skinTone : integer Optional

The skin tone, defaults to 1

Return Value

Type : string

The head component hash string

Example

lua
local ped = PlayerPedId() -- OR "mp_male"/"mp_female"
local headIndex = 1
local skinTone = 3
local hash = jo.component.getHeadFromSkinTone(ped, headIndex, skinTone)
print(hash)

Client jo.component.getPaletteNameFromHash()





A function to get the palette name from a hash value

Syntax

lua
jo.component.getPaletteNameFromHash(hash)

Parameters

hash : integer

The palette hash

Return Value

Type : string

The palette name, or "unknown" if not found

Example

lua
local paletteHash = 0xAA65D8A3
local palette = jo.component.getPaletteNameFromHash(paletteHash)
print(palette)
-- Expected output: `metaped_tint_generic`

Client jo.component.getTeethFromIndex()

A function to get the teeth component hash from an index

Syntax

lua
jo.component.getTeethFromIndex(ped, index)

Parameters

ped : integer|string

The entity ID or model name

index : integer Optional

The teeth index, defaults to 1

Return Value

Type : string

The teeth component hash string

Example

lua
local ped = PlayerPedId() -- OR "mp_male"/"mp_female"
local teethIndex = 3
local hash = jo.component.getTeethFromIndex(ped, index)
print(hash)

Client jo.component.getWearableState()

Get the wearable state of a category

Syntax

lua
jo.component.getWearableState(ped, category)

Parameters

ped : integer

The entity ID

category : string|integer

The category name

Return Value

Type : integer

Return the wearable state hash of the category

Example

lua
local ped = PlayerPedId()
local category = "neckwear"
local wearableState = jo.component.getWearableState(ped, category)
print(wearableState)

Client jo.component.getWearableStateNameFromHash()

Syntax

lua
jo.component.getWearableStateNameFromHash(state)

Example

lua
local hash = -1539589426
local stateName = jo.component.getWearableStateNameFromHash(hash)
print(stateName)
-- Expected output: `closed_collar_rolled_sleeve`

Client jo.component.hairIsPomade()

A function to know if the hair is pomaded

Syntax

lua
jo.component.hairIsPomade(ped)

Parameters

ped : integer

The entity ID

Return Value

Type : boolean

Return true if the hair is pomaded

Example

lua
local ped = PlayerPedId()
local isPomaded = jo.component.hairIsPomade(ped)
print(isPomaded)

Client jo.component.isCategoryEquiped()

A function to know if a specific category is equiped on the ped

Syntax

lua
jo.component.isCategoryEquiped(ped, category)

Parameters

ped : integer

The entity ID

category : string|integer

The category name

Return Value

Type : integer

Return the index of the category

Example

lua
local ped = PlayerPedId()
local category = "pants"
local isEquiped, index = jo.component.isCategoryEquiped(ped, category)
print(isEquiped, index)

Client jo.component.isMpComponent()

A function to check if a component is an MP component (multiplayer component)

Syntax

lua
jo.component.isMpComponent(ped, hash)

Parameters

ped : integer

The entity ID OR the metapedType

hash : integer

The component hash

Return Value

Type : boolean

Return true if it's an MP component, false otherwise

Example

lua
local ped = PlayerPedId()
local hash = 0x123456
local isMP = jo.component.isMpComponent(ped, hash)
print(isMP)

Client jo.component.loadoutIsOnRight()

A function to know if the loadout is on the right

Syntax

lua
jo.component.loadoutIsOnRight(ped)

Parameters

ped : integer

The entity ID

Return Value

Type : boolean

Return true if the loadout in on the right, false otherwise

Example

lua
local ped = PlayerPedId()
local isRight = jo.component.loadoutIsOnRight(ped)
print(isRight)

Client jo.component.neckwearIsUp()

Return if the neckwear is on the face of the player or not

Syntax

lua
jo.component.neckwearIsUp(ped)

Parameters

ped : integer

The entity ID

Return Value

Type : boolean

Return true if the neckwear is on the face, false otherwise.

Example

lua
local ped = PlayerPedId()
local isUp = jo.component.neckwearIsUp(ped)
print(isUp)

Client jo.component.refreshPed()





A function to refresh the ped components

Syntax

lua
jo.component.refreshPed(ped)

Parameters

ped : integer

The entity ID

Example

lua
local ped = PlayerPedId()
jo.component.refreshPed(ped)

Client jo.component.remove()

A function to remove a component component

Syntax

lua
jo.component.remove(ped, category)

Parameters

ped : integer

The entity ID

category : integer|string

The category of component to remove

Example

lua
local ped = PlayerPedId()
local category = "hats"
jo.component.remove(ped, category)

Client jo.component.removeAllClothes()

A function to remove all clothing components from a ped

Syntax

lua
jo.component.removeAllClothes(ped)

Parameters

ped : integer

The entity ID

Example

lua
local ped = PlayerPedId()
jo.component.removeAllClothes(ped)

Client jo.component.setWearableState()





A function to edit the wearable state of a category

Syntax

lua
jo.component.setWearableState(ped, category, data, state)

Parameters

ped : integer

The entity ID

category : integer|string

The category of the component

data : table

The component data, see the structure in jo.component.apply()

state : integer|string

The wearable state to apply on the component
The list of wearable state can be find in the jo_libs>module>component>client.lua file line 76

Example

lua
local ped = PlayerPedId()
local category = "neckwear"
local data = { hash = "CLOTHING_ITEM_F_NECKERCHIEF_000_TINT_001" }
local state = jo.component.wearableStates.neckwear[1] --neckwear UP
jo.component.setWearableState(ped, category, data, state)

Client jo.component.sleeveIsRolled()

Return if the sleeve are rolled

Syntax

lua
jo.component.sleeveIsRolled(ped)

Parameters

ped : integer

The entity ID

Return Value

Type : boolean

Return true if the sleeve are rolled, false otherwise.

Example

lua
local ped = PlayerPedId()
local isRolled = jo.component.sleeveIsRolled(ped)
print(isRolled)

Client jo.component.sleeveRoll()

A function to roll sleeve

Syntax

lua
jo.component.sleeveRoll(ped, data)

Parameters

ped : integer

The entity ID

data : table

The component data, see the structure in jo.component.apply()

Example

lua
local ped = PlayerPedId()
local data = { hash = "CLOTHING_ITEM_M_SHIRT_209_TINT_005" }
jo.component.sleeveRoll(ped, data)

Client jo.component.sleeveUnroll()

A function to unroll sleeve

Syntax

lua
jo.component.sleeveUnroll(ped, hash)

Parameters

ped : integer

The entity ID

data : table

The component data, see the structure in jo.component.apply()

Example

lua
local ped = PlayerPedId()
local data = { hash = "CLOTHING_ITEM_M_SHIRT_209_TINT_005" }
jo.component.sleeveUnroll(ped, data)

Client jo.component.vestIsUnderPant()

A function to know if the vest is under the pant

Syntax

lua
jo.component.vestIsUnderPant(ped)

Parameters

ped : integer

The entity ID

Return Value

Type : boolean

Return true if the vest is in the pant, false otherwise

Example

lua
local ped = PlayerPedId()
local isIn = jo.component.vestIsUnderPant(ped)
print(isIn)

Client jo.component.waitPedLoaded()

A function to wait the refresh of ped

Syntax

lua
jo.component.waitPedLoaded(ped)

Parameters

ped : integer

The entity ID

Example

lua
local ped = PlayerPedId()
local isIn = jo.component.waitPedLoaded(ped)

Shared jo.component.formatComponentData()





A function to format component data

Syntax

lua
jo.component.formatComponentData(_data, hashData)

Parameters

_data : string|number|table

The component data

hashData : boolean

Hash the value is true

Return Value

Type : any

Example

lua
local hash = "CLOTHING_ITEM_F_HAT_241_PANTHER_VAR_001"
local formattedData = jo.component.formatComponentData(hash)
log(formattedData)
--expected output: {hash = "CLOTHING_ITEM_F_HAT_241_PANTHER_VAR_001"}

Shared jo.component.getCategoryHash()

A fonction to get the category hash from its string

Syntax

lua
jo.component.getCategoryHash(category)

Parameters

category : string|integer

The category string

Return Value

Type : integer

The category hash

Example

lua
local category = "hats"
local hash = jo.component.getCategoryHash(category)
print(hash)
-- Expected output: -1725579161

Shared jo.component.getFullHorseComponentList()

A function to get the list of horse's components sorted by category

Syntax

lua
jo.component.getFullHorseComponentList()

Return Value

Type : table

Example

lua
local horseComponents = jo.component.getFullHorseComponentList()
for category,datas in pairs (horseComponents) do
  print(category, table.count(datas))
end

Shared jo.component.getFullPedComponentList()



A function to get the list of clothes sorted by sex and category

Syntax

lua
jo.component.getFullPedComponentList()

Return Value

Type : table

Example

lua
local pedComponents = jo.component.getFullPedComponentList()
for category,datas in pairs (pedComponents) do
  print(category, table.count(datas))
end

Last updated: