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:
hooks/server.lua— server hookshooks/client.lua— client hooks
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.
| Type | Return | Effect |
|---|---|---|
| gate | false, code? | Refuses the action. code is a locale key from locales/<lang>.json shown to the player. Returning nothing allows it. |
| filter | a new value | Replaces the value passed in. Returning nothing keeps it. |
| notify | ignored | Lets 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.FrameworkandConfig. - Client hooks can use
State,Store,Appearance,Preview,Bridge.FrameworkandConfig.
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
| Hook | Side | Type | Fires |
|---|---|---|---|
canOpenStore | server | gate | after the store, job lock and distance checks pass |
storePayload | server | filter | on everything the store UI is about to receive |
discount | server | filter | on the final discount rate |
canBuy | server | gate | right before the player is charged |
bought | server | notify | after a purchase |
canList | server | gate | before the listing fee is taken |
listed | server | notify | after a listing goes live |
earningsCollected | server | notify | after a seller collects their sales income |
canOpen | client | gate | before the server is asked to open the store |
opened | client | notify | the store UI is open |
closed | client | notify | the player is back on the street |
worn | client | notify | every try-on |
woreOut | client | notify | they left wearing an outfit they own |