For the complete documentation index, see llms.txt. This page is also available as Markdown.

NPC Examples

Ready-to-use npc_message scripts for Discord announcements

Ready-to-use npc_message scripts for server-generated announcements. Replace YOUR_CHANNEL_ID with your Discord channel ID.

The npc_message action is for messages your server sends on its own — events, maintenance notices, WoE status, staff alerts. It only needs name, message, and channel. (For player chat use Message Sync; for staff @request alerts see Ticket Support Command.)


It's just a script function

ragnascript() is a normal rAthena/Hercules script function — exactly like announce, mes, or getitem. That means it drops straight into any script your server already runs: NPCs, event labels (OnPCKillEvent, OnAgitStart, …), quest scripts, instances, functions, item bonus scripts, @command handlers — anywhere a script command is valid.

There's no limit on what you can announce. If rAthena/Hercules can script it, you can post it to Discord. The examples below are common starting points, not the boundary — wherever you can already write a line of script, you can add a ragnascript() call beside it. It's plug-and-play: paste the function in, set your channel, done.

Anything you can detect in script — a player hitting max level, a custom currency changing, an MVP spawning, a GM toggling an event — can trigger a Discord announcement. Just put the ragnascript() call wherever that logic already lives.


How npc_message works

Every npc_message call has the same three fields. That's the whole mechanic:

ragnascript("[action: npc_message][name: Town Crier][message: The shop is now open!][channel: YOUR_CHANNEL_ID]");

The syntax is always [action: npc_message] followed by the three fields, in any order:

ragnascript("[action: npc_message][name: <author>][message: <text>][channel: <id>]");
Field
Required
What it does

action

Yes

Always npc_message for these scripts. Tells RagnaSync this is an unattributed server announcement.

name

Yes

The author name shown in Discord. This is not a real player — it's whatever label you want the message to come from (System, WoE, Event Manager, …).

message

Yes

The text that appears in Discord. Plain text, and supports Discord emoji shortcodes + Markdown. Build it however you like — see below.

channel

Yes

The Discord channel ID the message is posted to. Different calls can target different channels.

No account_id or char_id is needed — npc_message is unattributed, so it never shows a player avatar or links to a character. That's exactly why it's the right action for anything the server says.

Choosing when it fires

The ragnascript() call is identical everywhere — what changes between implementations is the rAthena event label that triggers it. Pick the label that matches when you want the announcement to fire:

Trigger label
Fires when
Example below

OnInit

Once, when scripts finish loading (server boot)

OnHour00–OnHour23 / OnClockHHMM

At a fixed time of day

OnMinuteNN

Every hour at minute NN

OnAgitStart / OnAgitEnd

WoE begins / ends

OnNPCKillEvent

A monster dies (use killedrid)

OnPCKillEvent

A player kills another player/monster

function / callfunc

On demand, called from your other scripts

Anti-Bot Alerts (ReportBot)

These are standard rAthena/Hercules labels — RagnaSync doesn't add any of its own. Any event that can run script code can call ragnascript().

Building the message dynamically

message is just a string, so you can concatenate game data into it with +, the same as any rAthena script. Common sources for announcement text:

Function
Returns
Used in

strcharinfo(0)

The triggering player's name

strcharinfo(3)

The player's current map name

strmobinfo(1, <mobID>)

A monster's display name

getmonsterinfo(<id>, MOB_MVPEXP)

>0 for MVP mobs (filter kills)

getusers(1)

Online player count

gettime(DT_HOUR)

Current server hour (0–23)

Here's the pattern — pull a value, drop it into the message:

Even though you can reference the player who triggered the event (like strcharinfo(0) above), the message is still posted as the NPC name you set — not as that player. Use npc_message when you want the announcement in Discord, not a player-attributed chat line.


Event Announcements

Announce events to Discord automatically:


Server Maintenance Notice


WoE Status


Anti-Bot Alerts

Notify staff when suspicious activity is detected:

You can also trigger alerts from your existing anti-bot systems:


Server Online Notice

Post to Discord the moment the server finishes loading — OnInit runs once when scripts load:

Discord renders emoji shortcodes like :green_circle: and standard Markdown (**bold**, *italic*) inside the message text — handy for making announcements stand out.


MVP Kill Announcements

Announce who landed an MVP, with the boss name pulled straight from the mob database:


Routing to Different Channels

The channel field is just a variable — store your channel IDs once and route each announcement where it belongs:


Scheduled Server Stats

Build the message from live game data and post it on a timer. Here we report the online player count every hour:


Tips

Keep it to announcements - npc_message only requires name, message, and channel. There's no player attached, so use it for anything your server says on its own.

Mind the brackets - RagnaSync parses fields with [key: value], so avoid putting literal [ or ] inside your message text — they can confuse the parser. Stick to plain text, emoji, and Markdown.

One line per call - Keep each ragnascript("...") on a single line, even when concatenating with +. Build longer text in a .@msg$ variable first if it gets unwieldy, then pass .@msg$ as the message.

Rate limiting - For scripts that fire on frequent events (like OnPCKillEvent above), add a cooldown so you don't flood the channel:


Need the basics? See RagnaScript Overview.

Last updated