onShopClosed
Registers a callback that runs every time the clothing menu closes, whether the player bought something or backed out. It covers every menu that shares the shop UI: clothing, barber, tattoos, ped changer, surgery, wardrobe and styling sessions.
Use it to react to the menu going away, for example to resync an inventory's clothing slots with what the player is now wearing.
The character creator is a separate UI and does not report here when it is saved. Use onCharacterCreated for that.
๐ก Syntax
exports['kartik-clothing']:onShopClosed(function(data) end)๐ฅ Parameters
| Parameter | Type | Optional | Description |
|---|---|---|---|
cb | function | No | Called with the data table below each time the menu closes. |
data
| Field | Type | Description |
|---|---|---|
shopType | string? | The menu that closed: clothing, barber, tattoos, ped, wardrobe, styling, and so on. |
shopId | number? | Database id of the shop, when the menu was opened from one. |
purchased | boolean | true when the menu closed by confirming (purchase, wearing an outfit, finishing a styling session). false when the player backed out. |
cart | table? | Only on a purchase: the list of items bought, each { componentId | propId, drawable, texture, collection? }. |
appearance | table | The player's appearance after the menu closed. With Config.Inventory.Enabled, this is the outfit they walked in with, because purchases go to the inventory rather than onto the ped. |
๐ค Returns
| Type | Description |
|---|---|
boolean | true if the callback was registered. |
Callbacks are removed automatically when the resource that registered them stops, so it is safe to register again on restart.
๐ป Example
exports['kartik-clothing']:onShopClosed(function(data)
if not data.purchased then return end
print(('Closed %s, bought %d item(s)'):format(data.shopType or '?', data.cart and #data.cart or 0))
-- e.g. refresh your inventory clothing slots here
end)๐ก Event
The same payload is sent as a client event, if you prefer a handler to an export:
AddEventHandler('kartik-clothing:client:shopClosed', function(data)
print(data.shopType, data.purchased)
end)