RoyaleWindRoyaleWind

Hooks

Change how RW Fashion behaves without touching its escrowed code.

Hooks let you refuse, change or react to what the store does. They live in two files that stay readable under escrow:

Every hook is already written out in those files as a commented example. Uncomment it, change the body and restart the resource.

Hooks.on('canBuy', function(source, order)
    if order.total > 50000 and not IsPlayerAceAllowed(source, 'fashion.bigspender') then
        return false, 'no_access'
    end
end)

Hook types

Each hook is one of three types, and the type decides what your return value means.

TypeReturnEffect
gatefalse, code?Refuses the action. code is a locale key from locales/<lang>.json shown to the player. Returning nothing allows it.
filtera new valueReplaces the value passed in. Returning nothing keeps it.
notifyignoredLets you react after something happened.

Rules

  • You can register more than one listener for the same hook. They run in the order they were registered.
  • Every listener runs inside a pcall. A hook that errors is reported in the console and skipped, instead of breaking a purchase. A gate that errors counts as allowing the action — the built-in checks have already run by then.
  • Registering an unknown hook name, or something that isn't a function, prints an error listing the hooks that exist.
  • Server hooks can use Catalog, Wardrobe, Listing, Pricing, Db, Bridge.Framework and Config.
  • Client hooks can use State, Store, Appearance, Preview, Bridge.Framework and Config.

Client hooks aren't security. They can stop the store opening, but anything involving money is checked again on the server — put real rules in server hooks.

All hooks

HookSideTypeFires
canOpenStoreservergateafter the store, job lock and distance checks pass
storePayloadserverfilteron everything the store UI is about to receive
discountserverfilteron the final discount rate
canBuyservergateright before the player is charged
boughtservernotifyafter a purchase
canListservergatebefore the listing fee is taken
listedservernotifyafter a listing goes live
earningsCollectedservernotifyafter a seller collects their sales income
canOpenclientgatebefore the server is asked to open the store
openedclientnotifythe store UI is open
closedclientnotifythe player is back on the street
wornclientnotifyevery try-on
woreOutclientnotifythey left wearing an outfit they own

On this page