> For the complete documentation index, see [llms.txt](https://docs.ragnasync.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ragnasync.com/event-logs/economy/shop-log.md).

# Shop Logs

Logs NPC shop buy/sell transactions to Discord

The Shop Log feature tracks when players buy from or sell to NPC shops. This helps you understand your server's economy and monitor for unusual trading patterns.

## Action

`shop_log`

## When It's Used

This log is triggered when a player:

* **Buys items** from any NPC shop
* **Sells items** to any NPC shop

All items in a single transaction are batched together in one message.

## Why Use It

* **Monitor economy** by tracking zeny flow through NPC shops
* **Detect abuse** like item duplication or price exploits
* **Track popular items** to understand what players need
* **Audit transactions** for server administration

## Server Configuration

In `conf/channels.conf`:

```
// NPC shop transaction logging
ragnasync_shop_log_enabled: true
ragnasync_shop_log_channel_id: "YOUR_CHANNEL_ID"
ragnasync_shop_log_buy_enabled: true
ragnasync_shop_log_sell_enabled: true
ragnasync_shop_log_min_zeny: 1000000
ragnasync_shop_log_group_min: 0
ragnasync_shop_log_group_max: 0
```

| Setting        | Description                                 | Default |
| -------------- | ------------------------------------------- | ------- |
| `enabled`      | Enable/disable shop logging                 | `false` |
| `channel_id`   | Discord channel ID for shop logs            | -       |
| `buy_enabled`  | Log buy transactions                        | `true`  |
| `sell_enabled` | Log sell transactions                       | `true`  |
| `min_zeny`     | Minimum zeny threshold to log (0 = log all) | `0`     |
| `group_min`    | Minimum GM group level to log               | `0`     |
| `group_max`    | Maximum GM group level to log               | `99`    |

**Tip:** Set `min_zeny: 1000000` to only log transactions over 1 million zeny.

## Message Format

The default message shows player, items, quantities, and total prices:

```
🛒 Shop [Buy]:     | Knight           | Red Potion           x100   | 5,000z
🛒 Shop [Buy]:     | Knight           | Orange Potion        x50    | 10,000z
```

Multiple items in one transaction are grouped together.

## Data Fields

| Field         | Type   | Description                          |
| ------------- | ------ | ------------------------------------ |
| `type`        | string | Transaction type: `buy` or `sell`    |
| `player_name` | string | Character name                       |
| `list`        | string | Batched item data (see format below) |
| `pos`         | string | Player location: \`map               |
| `npc_id`      | int    | NPC ID (optional)                    |
| `account_id`  | int    | Player's account ID                  |
| `char_id`     | int    | Player's character ID                |
| `channel`     | string | Discord channel ID                   |

### List Format

Items are sent as a comma-separated list with pipe-delimited values:

```
item_id|item_name|amount|price,item_id|item_name|amount|price,...
```

**Example:**

```
501|Red Potion|100|5000,502|Orange Potion|50|10000
```

## Example Use Cases

### Economy Monitoring Channel

Track all NPC transactions in an admin channel:

```
ragnasync_shop_log_channel_id: "1234567890"  // #economy-logs
```

### Detect Unusual Activity

Large purchases from NPCs might indicate:

* Item price exploits
* Automated bots
* Economy manipulation

### Track Popular Items

See which items players buy most frequently to balance your server economy.

## Custom Messages

Want to customize how these messages look? Head to the **Message Routes** page on your dashboard, set the format to **Custom Message**, and compose your own template using `{{placeholder}}` syntax.

**Example template:**

```
:shopping_cart: {{player_name}} {{type}} items from the shop
```

**Available placeholders for this event:**

| Placeholder       | Example |
| ----------------- | ------- |
| `{{player_name}}` | Marky   |
| `{{type}}`        | buy     |

See [Message Routing](/ragnascript/message-routing.md) for more about formats, conditions, and multi-channel routing.

## Notes

* All items in a single shop transaction are sent together
* The `price` field shows the total cost (unit price × quantity)
* Position tracking (`pos`) helps identify which NPC was used
* Both buying and selling are tracked with the `type` field
