> For the complete documentation index, see [llms.txt](https://5scripts-1.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://5scripts-1.gitbook.io/docs/assets/5s_skinmenu/functions.md).

# Functions

## Exports

> **Note:** This documentation describes the exported functions that can be called from other resources. These functions provide external access to the 5s\_skinmenu system functionality.

***

### Server Side Exports

* **convertSkinOptionsToSkinChanger(options)**
  * Converts our skin options format to skinchanger for compatibility.
  * **Arguments:**
    * `options` *(table)*: Skin options as a table (for example decoded from database).
  * **Returns:** None (void function).
  * **Usage:** Allows to convert our skin options format to skinchanger.
  * **Example:**

    ```lua
    local options = json.decode(MySQL.scalar.await('SELECT skinData FROM your_skin_data_table'))

    local skinChangerOptions = exports['5s_skinmenu']:convertSkinOptionsToSkinChanger(options)
    ```
  * **Notes:**
    * Options must be the same as our script uses, otherwise this function may return invalid data.

### Client Side Exports

* **getClothingOptions(excludedComponents, excludedProps)**
  * Fetches current player clothing options excluding ones specified in arguments.
  * **Arguments:**
    * `excludedComponents` *(table)*: List of components which should be excluded.
    * `excludedProps` *(table)*: List of props which should be excluded.
  * **Returns:** Clothing options (components & props) with exclusions.
  * **Usage:** Allows to get clothing options to for example save outfits without facial data.
  * **Example:**

    ```lua
    local clothingOptions = exports['5s_skinmenu']:getClothingOptions()
    local clothingOptionsExcludingComponent = exports['5s_skinmenu']:getClothingOptions({}, {1}) -- Excludes prop with ID 1.
    ```
* **setClothingOptions(clothingOptions)**
  * Sets current player clothing to one passed in the argument.
  * **Arguments:**
    * `clothingOptions` *(table)*: Clothing options (for example ones from getClothingOptions).
  * **Returns:** None (void function).
  * **Usage:** Allows to set only clothing options from for example skin data.
  * **Example:**

    ```lua
    exports['5s_skinmenu']:setClothingOptions(someOptions)
    ```
* **getSkinOptions()**
  * Fetches whole player skin options.
  * **Returns:** Current skin options.
  * **Usage:** Allows to get full skin options of a player as they are.
  * **Example:**

    ```lua
    local currentSkin = exports['5s_skinmenu']:getSkinOptions()
    ```
* **setSkinOptions(skinOptions, ped)**
  * Sets skin options for a given ped.
  * **Arguments:**
    * `skinOptions` *(table)*: Skin options (for example ones from getSkinOptions).
    * `ped` *(number | null)*: Ped handle which you want to set skin options for (optional).
  * **Returns:** None (void function).
  * **Usage:** Allows to set full skin options for a ped (or local ped if not passed).
  * **Example:**

    ```lua
    local someOptions = exports['5s_skinmenu']:getSkinOptions()
    exports['5s_skinmenu']:setSkinOptions(someOptions)
    ```
* **getSkinOptionsDb()**
  * Fetches player skin data from the database.
  * **Returns:** Skin options saved in database.
  * **Usage:** Allows to get full skin options saved in the database.
  * **Example:**

    ```lua
    local skinFromDatabase = exports['5s_skinmenu']:getSkinOptionsDb()
    ```
* **saveSkinOptions()**
  * Saves player skin to the database.
  * **Returns:** A boolean which indicates if save was successful.
  * **Usage:** Allows to save player skin to the database.
  * **Example:**

    ```lua
    local success = exports['5s_skinmenu']:saveSkinOptions()
    ```
* **setPedModel(model)**
  * Sets the player model.
  * **Arguments:**
    * `model` *(number)*: Model hash.
  * **Returns:** None (void function).
  * **Usage:** Allows to set a custom player model.
  * **Example:**

    ```lua
    exports['5s_skinmenu']:setPedModel(`mp_m_freemode_01`)
    ```
* **setBaseModel(ped, gender)**
  * Sets a base model for a given gender.
  * **Arguments:**
    * `ped` *(number | null)*: Ped handle or null for the local player.
    * `gender` *('m' | 'f')*: Gender (m - male or f - female).
  * **Returns:** None (void function).
  * **Usage:** Allows to set a ped model according to the given gender.
  * **Example:**

    ```lua
    exports['5s_skinmenu']:setBaseModel(nil, 'm') -- Sets the male model for the local player
    ```
* **openSkinMenu(isClothingShop, isBarberShop)**
  * Opens the skin menu.
  * **Arguments:**
    * `isClothingShop` *(boolean)*: If should open in clothing shop mode.
    * `isBarberShop` *(boolean)*: If should open in barber shop mode.
  * **Returns:** None (void function).
  * **Usage:** Opens player the skin menu with set options.
  * **Example:**

    ```lua
    exports['5s_skinmenu']:openSkinMenu() -- Opens the skin menu normally.
    exports['5s_skinmenu']:openSkinMenu(true) -- Opens the skin menu in clothing shop mode.
    exports['5s_skinmenu']:openSkinMenu(false, true) -- Opens the skin menu in barber shop mode.
    ```
* **closeSkinMenu()**
  * Closes the skin menu.
  * **Returns:** None (void function).
  * **Usage:** Closes the skin menu.
  * **Example:**

    ```lua
    exports['5s_skinmenu']:closeSkinMenu()
    ```
* **openWardrobeMenu()**
  * Opens the wardrobe menu (if enabled).
  * **Returns:** None (void function).
  * **Usage:** You may open the wardrobe menu from a custom export.
  * **Example:**

    ```lua
    exports['5s_skinmenu']:openWardrobeMenu()
    ```

***

> Use these exports to integrate the 5s\_skinmenu system with your own resources.
