Skip to content

✂️ NPC Hairs & Beards ​

Documentation relating to the jo_hairdresser_npc add-on for the Hairdresser script.

1. Installation ​

WARNING

The Hairdresser script is required to use this add-on.

To install jo_hairdresser_npc:

  • Drag and drop the resource into your resources folder
    • jo_hairdresser_npc
  • Add this ensure to your server.cfg after ensure jo_hairdresser
    • ensure jo_hairdresser_npc

Congratulations, the NPC Hairs & Beards add-on is ready to use!

2. Usage ​

3. Configuration ​

The configuration files are located in the config folder within the resource. This folder contains two subfolders:

  • _default.lock/ - Contains the default configuration files. Do not edit these files directly as they may be overwritten during updates.
  • custom/ - This is where you place your custom configuration files to override the defaults.

How to customize the configuration ​

  1. Navigate to jo_hairdresser_npc/config/_default.lock/
  2. Copy the file you want to modify (e.g., prices.lua )
  3. Paste it into jo_hairdresser_npc/config/custom/
  4. Edit the copied file in the custom folder

The script automatically loads files from custom/ first, and only uses _default.lock/ as a fallback. This system ensures your customizations are preserved when updating the script.

Default configuration files ​

Loading configuration...

4. For developers ​

Filters ​

Filters allow you to modify data or permissions synchronously at specific points in the script.

Server canAccessToNPCMenu ​

Control access to the NPC hair and beard menus.

This filter works with Config.npcMenuAccessMode.

  • hide_locked - the filter is called with the display context. When it returns false, the add-on stays linked to Hairdresser but does not add its NPC entries to the menu. Players will see the same behavior as if the NPC add-on was not present: Hair and Beard open the native Hairdresser menus directly.
  • show_locked - NPC entries stay visible. The filter is called only with the open context when the player clicks an NPC entry. Return false to block the menu opening and optionally notify the player.

Available contexts:

  • display - checks if NPC entries should be added to the Hairdresser menus.
  • open - checks if the NPC menu can open after the player clicks an NPC entry.
lua
-- @param canAccess - boolean (default true)
-- @param source - serverID of the player
-- @param context - string ("display" or "open")
exports.jo_hairdresser_npc:registerFilter("canAccessToNPCMenu", function(canAccess, source, context)
    return canAccess
end)

Example - allow only VIP players:

lua
local vipPlayers = {}

exports.jo_hairdresser_npc:registerFilter("canAccessToNPCMenu", function(canAccess, source, context)
    return canAccess and vipPlayers[source] == true
end)

Example - keep NPC entries visible and notify only when the player clicks:

lua
-- config/_default.lock/global.lua or your custom config file
Config.npcMenuAccessMode = "show_locked"
lua
local isSubscriber = false

exports.jo_hairdresser_npc:registerFilter("canAccessToNPCMenu", function(canAccess, source, context)
    if context == "open" and not isSubscriber then
        jo.notif.rightError(source, "You can't access the NPC menu if you're not a subscriber")
    end

    return canAccess and isSubscriber
end)

Last updated: