> For the complete documentation index, see [llms.txt](https://atiysus-organization.gitbook.io/aty-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atiysus-organization.gitbook.io/aty-scripts/restaurant-creator/developer/events.md).

# Events

All events are namespaced `aty_restaurant:server:*` and `aty_restaurant:client:*`. Below are the integration-relevant ones. (Internal CRUD/sync events exist but are implementation details.)

#### Client → notification bridge

Trigger a notification on a specific client from the server:

```lua
TriggerClientEvent('aty_restaurant:client:ShowNotification', src,
    'success', 'Title', 'Message')
```

Or listen for the local notification event on the client:

```lua
RegisterNetEvent('aty_restaurant:client:ShowNotification', function(type, title, message)
    -- e.g. mirror ATY notifications into your own HUD
end)
```

#### Restaurant lifecycle (client)

| Event                                                            | Fired when                                                                                                     |
| ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `aty_restaurant:client:OnRestaurantSealed` (restId)              | A restaurant is sealed by the health inspector. Owner/staff are warned. Hook this for your own dispatch/alert. |
| `aty_restaurant:client:UpdateGlobalState` (action, restId, rest) | The server pushed a fresh copy of one restaurant to update the local cache live.                               |
| `aty_restaurant:client:RefreshPrepBoards` (boards)               | Prep board placements changed.                                                                                 |

#### Consumption

The script hooks the framework consume event defined by `Config.ConsumeEventName` (default `QBCore:Server:ConsumeItem`). Point this at your needs script's event to integrate hunger/thirst, or set `Config.DisableBuiltInConsumables = true` to let an external script own it.

For biometric effects on a custom consume flow, call the server export:

```lua
exports.aty_restaurant:HandleConsumption(src, itemName)
```

#### GlobalState you can read

The resource publishes live state you can read from any resource:

```lua
local restaurants = GlobalState.ATY_Restaurants
local pollutions  = GlobalState.ATY_RestaurantPollutions
local prepStock   = GlobalState.ATY_PrepStock
```

| Key                                       | Contents                                                            |
| ----------------------------------------- | ------------------------------------------------------------------- |
| `ATY_Restaurants`                         | All restaurants (owner, hygiene, reputation, stations, employees…). |
| `ATY_Freezers` / `ATY_PrepStock`          | Freezer & prep-board stock.                                         |
| `ATY_PrepBoards`                          | Prep board placements.                                              |
| `ATY_RestaurantPollutions`                | Active dirt/stain entities per restaurant.                          |
| `ATY_Dispensers` / `ATY_EspressoMachines` | Machine states.                                                     |
| `ATY_PizzaBoxes`                          | Dropped/placed pizza boxes.                                         |

{% hint style="warning" %}
These reflect live server state — treat them as read-only. Mutate restaurants through the provided flows, not by writing GlobalState directly.
{% endhint %}
