Hooks
A hook runs before LB Appearance does something, and can change or cancel it. The handler gets the hook’s data, and returns:
falseto cancel- new data to replace it
- nothing to keep the data as it is
| Hook | Side | Data | Runs before |
|---|---|---|---|
savingAppearance | Client | Appearance | The player’s appearance is saved |
savingOutfit | Client | Appearance | The player saves what they wear as an outfit |
usingOutfitBag | Client | UsingOutfitBagHookData | The player uses an outfit bag |
usingOutfitBag can only be cancelled.
---@class OutfitBagContents
---@field gender "male" | "female"
---@field clothes ClothingPiece[]
---@class UsingOutfitBagHookData
---@field worn ClothingPiece[] # The clothes that go into the bag
---@field contents? OutfitBagContents # The clothes that come out of the bag, nil when it's emptySee GetAppearance for Appearance, and lb-appearance:purchased for ClothingPiece.
RegisterHook
Registers a hook handler. The export returns an ID that can be passed to RemoveHook.
---@param name "savingAppearance" | "savingOutfit" | "usingOutfitBag"
---@param handler fun(data: any): any
---@return number hookId
local hookId = exports["lb-appearance"]:RegisterHook(name, handler)For example, stop players from using outfit bags while cuffed:
exports["lb-appearance"]:RegisterHook("usingOutfitBag", function()
if IsPedCuffed(PlayerPedId()) then
return false
end
end)Hooks are automatically removed when the resource that registered them stops.
RemoveHook
---@param hookId number
exports["lb-appearance"]:RemoveHook(hookId)