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.
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>]");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:
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:
Here's the pattern — pull a value, drop it into the message:
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:
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