motd.txt: Writing an HTML MOTD That Actually Renders

August 13, 2025 Daemon666 7 min read 11 visualizações

The message-of-the-day box that pops up when a player connects is rendered by motd.txt in your cstrike/ folder, shown in the game client's embedded HTML control. It is one of the few places you can put branding and rules in front of every visitor, and it is also one of the easiest to get subtly wrong — because the renderer is not a modern browser, and the file has a hard size limit that silently truncates anything too large.

1. Where it lives and what points at it

The file is cstrike/motd.txt, and the engine finds it through the motdfile cvar (default motd.txt). You can host multiple and switch:

// server.cfg
motdfile "motd.txt"

The window opens automatically on connect and can be re-opened by the client bind motd. Plugins frequently override it (a custom rules menu, a store panel), so if your file is ignored, check whether an AMXX plugin is calling show_motd with its own content.

2. Respect the size limit

The MOTD is delivered over the game channel and the classic engine truncates it at roughly 1500 bytes. Go over and the tail of your page simply never arrives, which looks like broken HTML — an unclosed table, a cut-off paragraph. Two rules follow:

  • Keep the file lean. Strip comments, collapse whitespace, do not paste a 40 KB exported web page into it.
  • If you need a real page — images, longer copy, styling — use URL mode instead of stuffing it inline.

3. URL mode: point the window at a web page

If motd.txt contains nothing but a single URL, the client treats it as an address and loads that page in the MOTD window instead of rendering the file as HTML:

https://your-domain.example/motd.html

This sidesteps the size limit entirely and lets you use a normal, cacheable web page. The trade-off: the client must be able to reach that URL, so it must be public HTTP(S) and reasonably fast, or the window hangs on connect. Do not point it at something that can go down — a broken MOTD URL greets every player with a blank or error box.

4. Write for the embedded renderer, not for Chrome

The in-game HTML control supports a small, old subset of HTML. Treat it like a very old browser:

  • Use inline styles and simple tags — <body>, <table>, <font>, <b>, <br>, <a>, <img>. Do not rely on external CSS files or JavaScript.
  • Set a background and text color explicitly; the default is not guaranteed.
  • Reference images by absolute https:// URL — the client fetches them over the network, they do not come from your game files.
<body bgcolor="#111111" text="#dddddd">
<table width="100%">
  <tr><td align="center">
    <font size="5" color="#66ccff"><b>My CS 1.6 Server</b></font><br>
    <font size="2">No cheating. No spawn-camping the hostages. Have fun.</font>
  </td></tr>
</table>
</body>

Keep links to a couple; the window is small and players close it fast.

5. Encoding and line endings

Save the file as plain ASCII/UTF-8 without a byte-order mark. A BOM or exotic encoding can make the first line render as garbage or push you over the byte limit unexpectedly. Windows editors that add a .txt a second time (so you end up with motd.txt.txt) are a recurring cause of "my MOTD does not show" — turn on file-extension display, the same trap that breaks server.cfg execution.

Common errors

  • Bottom of the MOTD is cut off — you exceeded the ~1500-byte limit. Trim the file or switch to URL mode.
  • Blank window on connect — URL mode pointing at an unreachable or slow page, or an AMXX plugin overriding the MOTD with empty content.
  • Images do not load — you used a relative path or http:// to a host that is down. Use absolute https:// URLs to a reliable host.
  • File is ignored entirely — a plugin is calling its own show_motd, or motdfile points somewhere else. Check the cvar and your plugin list.
  • First line renders as symbols — the file has a UTF-8 BOM. Re-save without it.

Verification

Connect from a real client — the MOTD window must open on join and render top to bottom with nothing truncated. Check the byte size on disk (wc -c cstrike/motd.txt); if it is near or over 1500, assume truncation and move to URL mode. If you edited it live, a reconnect is enough to reload it; no map change is required. To surface rules again during play, pair it with an adverts plugin that prints a short reminder in chat.

Colaboradores: Daemon666 ✦
Compartilhar: