Skip to content

MOTD: optional menu with links (Discord, website...) and antilag line - #509

Open
tibazera wants to merge 1 commit into
QW-Group:masterfrom
tibazera:feature/motd-links
Open

tibazera wants to merge 1 commit into
QW-Group:masterfrom
tibazera:feature/motd-links

Conversation

@tibazera

@tibazera tibazera commented Nov 24, 2026 •

Copy link
Copy Markdown

Why

Players often join a server without knowing where its community lives. They don't know the Discord, they have never heard of the league running on that server (for example qwleague.com), and nobody tells them. The MOTD is the first thing every player sees, so this PR lets admins turn it into a small guide:

  • colored lines (already possible with the &cRGB / &r markup, now shown in the example config)
  • an optional menu: "Discord", "Website", "Close"... The player selects an entry and the link opens in the browser.
  • an optional line that tells which antilag the server uses, so players know what they are playing on

The client part (openurl command with an on-screen Y/N confirmation) is QW-Group/ezquake-source#1218. Clients without it still get the link printed in their console.

All new keys are empty by default, so existing servers see no change.

Configuration

set k_motd1 "&cFD0Welcome!&r"
set k_motd2 "&c08FJoin our Discord&r"
set k_motd3 "&c4F1Sign up at example.com&r"

set k_motd_item1 "Discord|https://discord.gg/yourinvite"   // "Label|url": opens the link
set k_motd_item2 "Website|https://example.com"
set k_motd_item3 "Close"                                     // "Label" alone: closes the MOTD
set k_motd_menu_hint "(forward/back + jump)"                 // optional, this is the default
set k_motd_antilag "This server uses antilag"                // optional, adds "<text> <sv_antilag>" or "<text> off"

How the menu works

  • Forward/back moves the selection, jump confirms. The input is read from the movement field (forward move) and button2, so it works with whatever the player has bound: arrows, WASD... We first tried weapon keys 1..9 (impulses), but many configs bind them to weapon N, and the client does not send the impulse for a weapon the player does not have.
  • The selected entry is drawn as > Label < in gold, the others in gray. The MOTD is redrawn at once when the selection changes.
  • Each selection step needs a new press (edge triggered).
  • Label|url: prints Link: <url> to the player and stuffs openurl "<url>". The MOTD stays open, so after declining the link the player can pick another entry.
  • Label without url: closes the MOTD.
  • Firing still closes the MOTD, as before.

Security

The url goes into a stuffcmd, so urls containing ", ;, spaces or newlines are refused. The client side only accepts http(s) and asks the player before opening anything.

Code changes

src/motd.c

  • PMOTDThink(): after the k_motd lines, adds the optional antilag line and the menu (MOTDMenuText).
  • New helpers: MOTDItem(), MOTDItemCount(), MOTDFind().
  • MOTDMenuText(): builds the menu lines and the hint.
  • MOTDMenuInput(): per-frame input. Selection in motd->cnt, last direction in motd->count, last jump state in motd->lip.
dir = (self->movement[0] > 0) ? -1 : (self->movement[0] < 0) ? 1 : 0;
jump = (int)self->s.v.button2;
...
if (url && !strnull(url + 1) && !strpbrk(url + 1, "\"; \n\r"))
{
	G_sprint(self, PRINT_HIGH, "&c08FLink:&r %s\n", url + 1);
	stuffcmd(self, "openurl \"%s\"\n", url + 1);
}

src/client.c: PlayerPostThink() calls MOTDMenuInput() before W_WeaponFrame(). It returns at once when there is no menu or no MOTD for that player.

resources/example-configs/ktx/port1.cfg: commented example of the new keys.

Testing

MVDSV + KTX from QW-Group master on Linux (WSL), client from the ezQuake PR on Windows:

  • colored MOTD, menu with forward/back + jump, using both arrows and WASD binds
  • links open after Y in the client, N keeps the MOTD open
  • "Close" closes the MOTD, firing still closes it
  • antilag line follows sv_antilag (2, or off with 0)
  • with no k_motd_item* / k_motd_antilag set, the MOTD is identical to before

A short video of the feature is attached below.

🤖 Generated with Claude Code

New players often join a server without knowing where its community
lives (Discord, league site, rules...). The MOTD is the first thing they
see, so it is the natural place to point them there.

k_motd_item1..9 add a small menu under the k_motd lines:
  set k_motd_item1 "Discord|https://discord.gg/invite"
  set k_motd_item2 "Website|https://example.com"
  set k_motd_item3 "Close"
Forward/back moves the selection (read from the movement field, so it
works with any binds: arrows, WASD...), jump confirms. "Label|url" sends
"openurl <url>" to the client and prints the link to the console, so
clients without openurl still see it. "Label" alone closes the MOTD. URLs
with quotes, semicolons, spaces or newlines are refused because they go
into a stuffcmd.

k_motd_menu_hint changes the hint line (default "(forward/back + jump)").
k_motd_antilag "This server uses antilag" adds a line with the current
sv_antilag value (or "off"), so players know what they are playing on.

All new keys are empty by default, so existing servers see no change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant