> 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/features/ticket-system.md).

# Tickets

In-game support tickets with Discord integration

Let players open support tickets from in-game that create private Discord channels for your staff to respond.

***

## How It Works

```
Player opens ticket → Private Discord channel created → Staff replies → Player receives whisper
```

1. **Player sends a ticket message** using the `ticket` action
2. **RagnaSync creates a private channel** named `ticket-{playername}` in your Discord
3. **Staff type in the channel** and their messages whisper directly to the player
4. **Ticket closes** when the player logs out or staff uses `/close_ticket`

***

## Setting Up Ticket Support

### Create the Support NPC

Place this NPC where players can easily find it:

```c
prontera,156,180,4	script	Support	100,{
    mes "[Support]";
    mes "Need help? Open a ticket and staff will respond.";
    mes " ";
    mes "Your messages go directly to our Discord support team.";
    next;

    if (select("Open/Send Ticket:Cancel") == 2) close;

    mes "[Support]";
    mes "Type your message:";
    next;

    input .@message$;

    if (.@message$ == "") {
        mes "[Support]";
        mes "You didn't enter a message.";
        close;
    }

    // Send ticket message
    ragnascript("[action: ticket][account_id: " + getcharid(3) + "][char_id: " + getcharid(0) + "][name: " + strcharinfo(0) + "][message: " + .@message$ + "]");

    mes "[Support]";
    mes "Your message has been sent!";
    mes " ";
    mes "Staff will reply via whisper. Keep an eye on your chat.";
    close;
}
```

***

## What Happens in Discord

When a player sends their first ticket message:

1. A new channel `#ticket-playername` appears in your Discord server
2. The channel is created inside a category (default: **Tickets**)
3. The channel is private (only visible to staff with the right permissions)
4. Staff see a welcome message with the player's name
5. The player's message appears in the channel

{% hint style="info" %}
You can change the category name (up to 100 characters — e.g. "Support" or "Player Help") on the **Configure** page in your dashboard, under the **Ragnarok** section. If the category doesn't exist yet, RagnaSync creates it automatically.
{% endhint %}

The channel topic reads *"Type here to reply to PlayerName in-game"* — it's descriptive text only. You can edit or translate it without breaking anything; routing is handled automatically behind the scenes.

**Example:**

```
╔══════════════════════════════════╗
║     Support Ticket Opened        ║
╠══════════════════════════════════╣
║  Player: Zeny_Master             ║
║                                  ║
║  Type here to reply to the       ║
║  player in-game.                 ║
╚══════════════════════════════════╝

Zeny_Master: Hi, I lost my items after the server crash yesterday. Can you help?
```

***

## Replying to Players

Simply type in the ticket channel. Your message will be whispered to the player in-game:

| Discord                          | In-Game                                                   |
| -------------------------------- | --------------------------------------------------------- |
| `Have you checked your storage?` | Player sees: `@StaffName: Have you checked your storage?` |

The player can reply by talking to the Support NPC again - their messages appear in the same Discord channel.

***

## Closing Tickets

Tickets close automatically when:

* **Player logs out** - Channel is deleted after a brief moment
* **Staff uses `/close_ticket`** - Type this command in the ticket channel

When a ticket closes:

1. A "Ticket Closed" message appears in the channel
2. The Discord channel is deleted after 2 seconds
3. Database records are cleaned up

***

## Multiple Messages

Players can send multiple messages to the same ticket. Each message from the NPC goes to the existing ticket channel:

```c
// First message creates the ticket
ragnascript("[action: ticket][account_id: ...][char_id: ...][name: PlayerName][message: First message]");

// Second message goes to the same channel
ragnascript("[action: ticket][account_id: ...][char_id: ...][name: PlayerName][message: Follow-up message]");
```

***

## RagnaScript Format

```
[action: ticket][account_id: X][char_id: X][name: X][message: X]
```

| Field        | Required | Description                              |
| ------------ | -------- | ---------------------------------------- |
| `action`     | Yes      | Must be `ticket`                         |
| `account_id` | Yes      | Player's account ID                      |
| `char_id`    | Yes      | Player's character ID                    |
| `name`       | Yes      | Character name (used for channel naming) |
| `message`    | Yes      | The support message (max 500 characters) |

***

## Tips

**Channel naming** - Ticket channels are named `ticket-{name}` in lowercase. Special characters in names are handled automatically.

**Staff permissions** - Make sure your support staff have permission to see the ticket channels in Discord.

**Rate limiting** - Consider adding a cooldown to prevent ticket spam:

```c
if (gettimetick(2) - @last_ticket < 30) {
    mes "Please wait before sending another message.";
    close;
}
@last_ticket = gettimetick(2);
```

**Offline players** - If a player logs out and staff replies, the message won't be delivered. The ticket channel will already be closed by then.

***

## Quick Reference

| Action                     | What Happens                        |
| -------------------------- | ----------------------------------- |
| Player sends first ticket  | New `#ticket-name` channel created  |
| Player sends more messages | Messages appear in existing channel |
| Staff types in channel     | Player receives whisper in-game     |
| Player logs out            | Ticket channel deleted              |
| Staff uses `/close_ticket` | Ticket channel deleted              |

***

Need help with other features? Check out [RagnaScript Overview](/ragnascript/scripts.md).
