Skip to content

Component Client

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

JO Variables

jo.component.categoryName

Type : table

Links between the hash and name of a category.

key: category hash
value: category name

jo.component.order

Type : table

The order to apply the component

key: order to apply the component
value: category name

jo.component.wearableStates

Type : table

The list of available wearable state by category

key: category name
value: table of wearable states

JO Functions

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)

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)

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)

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)

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)

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)

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)

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)

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)

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 : object

Return an object 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)
print(json.encode(categories))
-- Expected output: categories = { 539411565 = {index = 1, category = "shirts_full"}, 491541130 = { index = 2, category = "pants"} }

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`

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 : object|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)

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

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 : integer|boolean

Return the hash of the component or false is not equiped

Example

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

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)
print(json.encode(components))

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)

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

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

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)

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`

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)

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 : string

Return the wearable state of the category

Example

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

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)

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 : boolean,integer

1st: Return true if the category is equiped, false otherwise
2nd: 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)

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

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)

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)

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)

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)

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)

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)

jo.component.setWearableState()

A function to edit the wearable state of a category

Syntax

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

Parameters

ped : integer

The entity ID

category : integer|string

The category of the component

data : object

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)

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)

jo.component.sleeveRoll()

A function to roll sleeve

Syntax

lua
jo.component.sleeveRoll(ped, hash)

Parameters

ped : integer

The entity ID

data : object

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)

jo.component.sleeveUnroll()

A function to unroll sleeve

Syntax

lua
jo.component.sleeveUnroll(ped, hash)

Parameters

ped : integer

The entity ID

data : object

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)

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)

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)

Last updated: