Resources

100 GMCP resources for MUD players

GMCP (Generic MUD Communication Protocol) leverages Telnet option 201 to facilitate structured data exchange between MUD servers and clients using JSON payloads. This resource provides technical specifications and implementation patterns for developers to move beyond screen-scraping, enabling modern UI features like auto-mapping, health gauges, and dedicated communication windows.

100 GMCP resources for MUD players illustration
Placeholder illustration shown while custom artwork is being produced.

Server-Side Protocol Implementation

  1. 1

    Telnet Negotiation Handshake

    beginnerhigh

    Send IAC WILL GMCP (255 251 201) to the client during the initial login sequence. If the client responds with IAC DO GMCP (255 253 201), the out-of-band channel is established.

  2. 2

    IAC SB GMCP Framing

    intermediatestandard

    Wrap all GMCP payloads in Subnegotiation markers. Format: IAC SB GMCP <Package.Message> <JSON data> IAC SE. Ensure no raw text or ANSI codes leak into this stream.

  3. 3

    JSON Library Integration

    intermediatehigh

    Use a robust C/C++ library like cJSON or RapidJSON. Avoid manual string concatenation for JSON to prevent malformed payloads when player names contain quotes or special characters.

  4. 4

    Core.Hello Processing

    beginnerstandard

    Parse the client's initial Core.Hello message to identify the client name and version (e.g., 'Mudlet 4.17'). Use this to toggle client-specific workarounds or features.

  5. 5

    Core.Supports.Set Handler

    intermediatestandard

    Track the packages the client explicitly requests. Do not send Char.Vitals or Room.Info until the client confirms support via the Core.Supports.Set or Add messages.

  6. 6

    Message Rate Limiting

    advancedmedium

    Implement a throttle for high-frequency updates like Char.Vitals. Limit updates to 100ms intervals to prevent client lag during rapid combat rounds or heavy regeneration.

  7. 7

    Null Byte Termination

    intermediatemedium

    Some legacy clients require a null byte (\0) at the end of the JSON payload before the IAC SE. Test compatibility across Mudlet, Mushclient, and BeipMU.

  8. 8

    Handling IAC DONT GMCP

    beginnerstandard

    If a player disables GMCP or switches to a non-compliant proxy, the server must receive IAC DONT GMCP and immediately stop all subnegotiation to prevent protocol desync.

  9. 9

    Namespace Management

    beginnerstandard

    Use standard package names (Core, Char, Room, Comm) for compatibility. Use a unique game-specific prefix (e.g., 'MyMUD.Quest') for custom game mechanics.

  10. 10

    Asynchronous Event Triggers

    advancedhigh

    Hook your GMCP broadcast functions into your game engine's event system (e.g., on_damage, on_move) rather than polling player state in the main loop.

Standard Package Specifications

  1. 1

    Char.Vitals Structure

    beginnerhigh

    Send current and max values for hp, mana, and moves. Example: { "hp": 150, "maxhp": 200 }. Essential for client-side health bars.

  2. 2

    Room.Info for Mapping

    intermediatehigh

    Provide 'num' (unique ID), 'name', 'zone', and 'exits' (a map of directions to room IDs). This allows Mudlet's mapper to build an accurate layout.

  3. 3

    Comm.Channel Routing

    beginnerstandard

    Send chat messages with 'chan' and 'msg' keys. This allows clients to capture 'gossip' or 'clan' chat into separate scrollable windows.

  4. 4

    Char.Items.List

    intermediatemedium

    Send a list of items in a specific location (inv, room, or container). Include 'id', 'name', and optional 'icon' for graphical inventory systems.

  5. 5

    Char.Status Updates

    beginnerstandard

    Transmit character-level metadata like level, race, class, and current gold. Update this only on state change to save bandwidth.

  6. 6

    Room.Players and Room.NPCs

    intermediatemedium

    Send arrays of entities present in the current room. Useful for creating clickable 'target' lists in the client UI.

  7. 7

    Char.Skills.Groups

    advancedstandard

    List skill categories available to the player. Used to populate client-side spellbooks or talent trees without querying the server manually.

  8. 8

    Core.Ping Latency Tracking

    beginnermedium

    Respond to a client Core.Ping with a server-side timestamp. Helps players diagnose network issues versus server processing lag.

  9. 9

    Char.Afflictions and Defences

    advancedhigh

    Send active debuffs (poison, blind) and buffs (shield, haste). Essential for high-level automated combat scripting in modern clients.

  10. 10

    Room.WrongDir Feedback

    intermediatestandard

    Notify the client when a movement fails (e.g., 'The door is locked'). Prevents the client-side mapper from desyncing when a move command is sent.

Client Integration and Debugging

  1. 1

    Mudlet event handlers

    beginnerhigh

    Register functions using registerAnonymousEventHandler('gmcp.Char.Vitals', 'myCallback'). This is more efficient than checking the gmcp table in a loop.

  2. 2

    Visualizing Payloads with display()

    beginnerstandard

    Use the Mudlet command 'lua display(gmcp)' to see the current state of all received data packages in the debug console.

  3. 3

    Geyser Gauge Binding

    intermediatehigh

    Directly link GMCP vital values to Geyser.Gauge objects. Update the gauge's value inside the gmcp.Char.Vitals event handler.

  4. 4

    Handling JSON Escaping Errors

    intermediatestandard

    If the client debug console shows 'JSON error', check for unescaped newlines or backslashes in the server-side string serialization.

  5. 5

    Client-Side Capability Requests

    beginnerstandard

    Use sendGMCP('Core.Supports.Add ["Comm.Channel 1"]') to tell the server your script is ready to process specific data streams.

  6. 6

    MUSHclient Plugin Integration

    advancedmedium

    Use the OnPluginTelnetSubnegotiation callback to capture option 201. Use a Lua JSON module to decode the buffer into a table.

  7. 7

    Automated Map Syncing

    intermediatehigh

    Trigger centerview(gmcp.Room.Info.num) whenever the Room.Info package arrives to keep the visual map locked to the player's position.

  8. 8

    Custom UI Widget Toggles

    intermediatemedium

    Show or hide UI elements based on GMCP data (e.g., hide the 'Mount' gauge if gmcp.Char.Status.mounted is false).

  9. 9

    GMCP to Discord Webhooks

    advancedmedium

    Use client-side scripts to bridge GMCP Comm.Channel data to Discord webhooks for out-of-game monitoring of guild chats.

  10. 10

    Debugging with Wireshark

    advancedstandard

    Use Wireshark with the Telnet filter to inspect the raw hex bytes of GMCP subnegotiations if the client is failing to parse the JSON.