Kartik Scripts

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

ParameterTypeOptionalDescription
cbfunctionNoCalled with the data table below each time the menu closes.

data

FieldTypeDescription
shopTypestring?The menu that closed: clothing, barber, tattoos, ped, wardrobe, styling, and so on.
shopIdnumber?Database id of the shop, when the menu was opened from one.
purchasedbooleantrue when the menu closed by confirming (purchase, wearing an outfit, finishing a styling session). false when the player backed out.
carttable?Only on a purchase: the list of items bought, each { componentId | propId, drawable, texture, collection? }.
appearancetableThe 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

TypeDescription
booleantrue 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)

On this page