legacy-shops
Integration
Exports and events for opening UIs, managing shops, and reacting to shop changes.
Integration
Client exports
OpenStore
Opens the store NUI for a given shop.
-- any client script
exports['legacy-shops']:OpenStore(shopId)
- No-ops silently if a UI is already open, or shows an error
lib.notifyif the server'slegacy-shops:openStorecallback returns nil (e.g. shop doesn't exist or job lock fails).
OpenCreator
Opens the admin shop creator NUI.
-- any client script
exports['legacy-shops']:OpenCreator()
- Requires the caller to be an admin (checked server-side); non-admins get an error notify and nothing opens.
Server callbacks (ox_lib lib.callback)
All of these are registered server-side and are primarily used by the bundled NUI, but can be invoked from your own server code with lib.callback.await or from a client with the matching client-side await pattern.
-- server-side example: fetch the shop list
local shops = lib.callback.await('legacy-shops:getShopList', source)
| Callback | Args | Notes |
|---|---|---|
legacy-shops:getInitData |
src |
Returns locale, isAdmin, pedPresets, shopPresets, theme fields |
legacy-shops:getPresets |
src |
Admin-only |
legacy-shops:savePreset |
src, data |
Admin-only. data.id present = update |
legacy-shops:deletePreset |
src, presetId |
Admin-only |
legacy-shops:getShops |
src |
Admin-only, summary list |
legacy-shops:createShop |
src, data |
Admin-only. Broadcasts legacy-shops:syncShops |
legacy-shops:updateShop |
src, data |
Admin-only. Broadcasts legacy-shops:syncShops |
legacy-shops:deleteShop |
src, shopId |
Admin-only. Broadcasts legacy-shops:syncShops |
legacy-shops:getCategories |
src, shopId |
No admin gate |
legacy-shops:saveCategory |
src, data |
Admin-only |
legacy-shops:deleteCategory |
src, categoryId |
Admin-only, cascades to items |
legacy-shops:getItems |
src, shopId |
No admin gate |
legacy-shops:saveItem |
src, data |
Admin-only |
legacy-shops:deleteItem |
src, data |
Admin-only (data.id, data.shop_id) |
legacy-shops:getAllItems |
src |
Admin-only, item picker source |
legacy-shops:getShopList |
src |
No admin gate, full shop array for ped/blip placement |
legacy-shops:openStore |
src, shopId |
Returns nil if shop missing or job-locked |
legacy-shops:purchase |
src, data |
Validates access, stock, licence, grade, currency; returns { success, message, items, balance } |
Events
legacy-shops:openCreator (client event)
Fired at a specific player to open the creator UI locally. Trigger it yourself if you want a custom command/menu entry to open the creator instead of Config.CreatorCommand:
-- server-side file, e.g. your own admin menu resource
TriggerClientEvent('legacy-shops:openCreator', targetSrc)
legacy-shops:syncShops (server → all clients)
Broadcast whenever shop data changes (create/update/delete a shop, or a preset edit propagates). If you create/modify shops directly (not recommended — use the callbacks above), trigger this yourself so clients refresh:
-- server-side file
TriggerClientEvent('legacy-shops:syncShops', -1)
legacy-shops:stockUpdated (server → all clients)
Broadcast after a restock sweep or price fluctuation regeneration. Currently a no-op on the client (empty handler) — listen for it yourself in your own client resource if you need to refresh a custom UI:
-- client-side file
AddEventHandler('legacy-shops:stockUpdated', function()
-- refresh your own UI here
end)
Optional legacy-blipmanager integration
If legacy-blipmanager is present, legacy-shops listens for these on the client (handled internally in client/shops.lua — you don't need to call these yourself unless you're building a blipmanager-compatible resource):
legacy-blipmanager:modeChanged(id, mode)— only acts whenid == 'shops'legacy-blipmanager:ready— triggers re-registration of shop blips after a blipmanager restart