> For the complete documentation index, see [llms.txt](https://doc.var-fivem.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.var-fivem.com/coins-shop/configuration/server-event.md).

# Server event

Events you can listen to from your own resources. They are fired during the script's normal lifecycle (delivery, subscriptions, etc.).

### Delivery events

| Event                     | Arguments                            | Trigger                                      |
| ------------------------- | ------------------------------------ | -------------------------------------------- |
| `var-shop:deliver`        | `(src, identifier, items)`           | Fires on every delivery (framework-agnostic) |
| `var-shop:deliver:esx`    | `(src, identifier, items, xPlayer)`  | Fires when ESX is detected                   |
| `var-shop:deliver:qbcore` | `(src, identifier, items, qbPlayer)` | Fires when QBCore is detected                |

`items` is an array of:

```lua
{
  { id = "rebla", label = "Rebla GTS", kind = "vehicle", qty = 1, meta = { upgrades = { "perf" } } },
  { id = "WEAPON_AK4K", label = "AK-4K", kind = "weapon", qty = 1 },
}
```

### Subscription events

| Event                             | Arguments                                 | Trigger                           |
| --------------------------------- | ----------------------------------------- | --------------------------------- |
| `var-shop:subscription:activated` | `(source, identifier, plan, state, item)` | A subscription was just activated |
| `var-shop:subscription:expired`   | `(identifier, state)`                     | A subscription expired            |
| `var-shop:subscriptions:updated`  | `(plans)`                                 | Plans list updated at runtime     |

### Example : grant priority queue on VIP subscription

```lua
AddEventHandler("var-shop:subscription:activated", function(source, identifier, plan, state, item)
  if plan.id == "sub_vip" then
    exports['my-priority']:grantPriority(identifier, plan.durationDays)
  end
end)
```

### Example : log every delivery

```lua
AddEventHandler("var-shop:deliver", function(src, identifier, items)
  print(("[shop-log] %s received %d item(s)"):format(identifier, #items))
end)
```

### Custom delivery routing

If you want to route a specific item kind to your own event, configure it in `shared/config.lua`:

```lua
Delivery = {
  Handlers = {
    vehicle = { Event = "myserver:giveVehicle" },
  },
  FallbackEvent = "var-shop:deliver:item",
}
```

Your event handler receives `(src, identifier, item)`.

See Delivery customization for the full picture.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.var-fivem.com/coins-shop/configuration/server-event.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
