Skip to Content

Custom Tabs

Other resources can add their own tabs and categories to the appearance menu with client exports. A category is built from components, such as image grids, sliders and color pickers, and your resource applies the values that the player picks.

Tabs and categories are automatically removed when the resource that added them stops.

Exports

AddCustomTab

Adds a tab with its own categories.

---@class CustomTabOptions ---@field id string ---@field label string ---@field icon? string ---@field after? string # Places the tab after the tab with this id ---@field categories CustomCategoryOptions[] ---@param tab CustomTabOptions ---@return boolean success ---@return "TAB_ALREADY_EXISTS" | nil reason local success, reason = exports["lb-appearance"]:AddCustomTab(tab)

RemoveCustomTab

---@param id string ---@return boolean success ---@return "INVALID_TAB" | "WRONG_RESOURCE" | nil reason local success, reason = exports["lb-appearance"]:RemoveCustomTab(id)

AddCustomCategory

Adds a category to a built-in tab (appearance, clothes, hair, accessories or tattoos) or to a custom tab.

---@param tab string ---@param category CustomCategoryOptions ---@return boolean success ---@return "INVALID_TAB" | "CATEGORY_ALREADY_EXISTS" | nil reason local success, reason = exports["lb-appearance"]:AddCustomCategory(tab, category)

RemoveCustomCategory

---@param tab string ---@param id string ---@return boolean success ---@return "INVALID_CATEGORY" | "WRONG_RESOURCE" | nil reason local success, reason = exports["lb-appearance"]:RemoveCustomCategory(tab, id)

UpdateCustomCategory

Updates the values, hidden components or items of a category while the menu is open.

---@param tab string ---@param id string ---@param state CustomCategoryState ---@return boolean success ---@return "INVALID_CATEGORY" | "WRONG_RESOURCE" | nil reason local success, reason = exports["lb-appearance"]:UpdateCustomCategory(tab, id, state)

Categories

The handlers of a category get the ped that is being edited. onOpen, onChange and onClick can return a CustomCategoryState to update the category, or false and an error message to reject the change.

---@class CustomGridValue ---@field x number ---@field y number ---@class CustomCategoryState ---@field values? table<string, string | number | boolean | CustomGridValue> # The values of the components, by component id ---@field hidden? string[] # The ids of the components to hide ---@field items? table<string, CustomOption[]> # The items of the images components, by component id ---@class CustomCategoryOptions ---@field id string ---@field label string ---@field icon? string ---@field after? string # Places the category after the category with this id ---@field camera? "full" | "head" | "upper" | "lower" | "feet" | "hands" | "leftHand" | "rightHand" # Defaults to "full" ---@field takeOffClothes? boolean ---@field components CustomComponent[] ---@field onOpen? fun(ped: number): CustomCategoryState | false | nil, string? ---@field onChange? fun(id: string, value: string | number | boolean | CustomGridValue, preview: boolean, ped: number): CustomCategoryState | false | nil, string? ---@field onClick? fun(id: string, ped: number): CustomCategoryState | false | nil, string? ---@field onSave? fun(ped: number) ---@field onClose? fun(saved: boolean, ped: number)
HandlerCalled when
onOpenThe player opens the category
onChangeThe player changes a component. preview is true while they drag an xgrid or xygrid component
onClickThe player clicks a button component
onSaveThe appearance is saved, for each category that was opened
onCloseThe menu closes, for each category that was opened

The menu can stay open after saving. When onClose gets saved = false, undo the changes made since the last onSave. Categories without onSave get saved = true once the appearance was saved.

Components

---@class CustomOption ---@field value string | number ---@field label? string ---@field image? string ---@field variants? CustomOption[] ---@class CustomColor ---@field value string | number ---@field r number ---@field g number ---@field b number ---@field label? string ---@class CustomComponentTab ---@field id string ---@field label string ---@field components? CustomComponent[] ---@class CustomComponent ---@field id string ---@field type "images" | "variants" | "colors" | "tabs" | "slider" | "opacity" | "switch" | "xgrid" | "xygrid" | "button" ---@field label? string ---@field items? CustomOption[] # images ---@field image? string # images, variants: {value} and {index} (and {parent} for variants) are replaced ---@field itemLabel? string # images: {value} and {index} are replaced ---@field none? true | string # images: adds a "none" option ---@field search? boolean # images ---@field fill? boolean # images ---@field source? string # variants: the id of the images component whose selected option's variants are shown ---@field colors? "hair" | "makeup" | CustomColor[] # colors ---@field tabs? CustomComponentTab[] # tabs ---@field min? number # slider, xgrid ---@field max? number # slider, xgrid ---@field step? number # slider ---@field labels? string[] # xgrid ---@field labelsX? string[] # xygrid ---@field labelsY? string[] # xygrid
TypeValue
imagesThe value of the selected option, or false for the “none” option
variantsThe value of the selected variant
colorsThe index of the color for "hair" and "makeup", otherwise its value
tabsThe id of the selected tab
sliderA number from min to max
opacityA number from 0 to 1
switchtrue or false
xgridA number from min to max. They default to -1 and 1
xygridA CustomGridValue
buttonNone. Clicking it calls onClick

Icons and images are URLs, or paths to files in your resource. Files in your resource need to be listed under files in its fxmanifest.lua.

Example

This adds a category to the clothes tab where the player picks the color of their parachute smoke trail. The color picker is hidden while the smoke trail is turned off.

local colors = { { value = 1, r = 200, g = 40, b = 40, label = "Red" }, { value = 2, r = 40, g = 160, b = 70, label = "Green" }, { value = 3, r = 40, g = 90, b = 200, label = "Blue" } } local saved = { enabled = false, color = 1 } local current = { enabled = false, color = 1 } local function ApplySmoke() local playerId = PlayerId() local color = colors[current.color] SetPlayerParachuteSmokeTrailColor(playerId, color.r, color.g, color.b) SetPlayerCanLeaveParachuteSmokeTrail(playerId, current.enabled) end exports["lb-appearance"]:AddCustomCategory("clothes", { id = "parachuteSmoke", label = "Parachute smoke", after = "parachute", components = { { id = "enabled", type = "switch", label = "Smoke trail" }, { id = "color", type = "colors", label = "Color", colors = colors } }, onOpen = function() return { values = current, hidden = current.enabled and {} or { "color" } } end, onChange = function(id, value) current[id] = value ApplySmoke() return { hidden = current.enabled and {} or { "color" } } end, onSave = function() saved = { enabled = current.enabled, color = current.color } end, onClose = function(wasSaved) if not wasSaved then current = { enabled = saved.enabled, color = saved.color } ApplySmoke() end end })