MUD eXtension Protocol (MXP)

MXP is an open MUD communication protocol pioneered by z/CMUD to enhance the communication between MUD servers and clients that support the protocol.

More information about MXP can be found at http://www.zuggsoft.com/zmud/mxp.htm

Summary
MXP is an open MUD communication protocol pioneered by z/CMUD to enhance the communication between MUD servers and clients that support the protocol.
To enable MXP on a specific node, set node[].mxp to 1.
MXP commands should be preceded by an ANSI escape sequence to make MXP tags difficult to send by other players.
To send an MXP tag, surround the MXP tag text with the ASCII characters ETX and EOT (characters with byte values 3 and 4, respectively).
The MXP specification also requires that the client be able to send secure messages to the MUD server (most notably for the <VERSION> and <SUPPORT> identification commands).
This block of code will return the text required to create a clickable MXP command.

Enabling MXP

To enable MXP on a specific node, set node[].mxp to 1.  As long as MXP is enabled on that node, all >, <, and & characters will be automatically converted to their HTML counterparts (required by the MXP specification).

MXP control sequences

MXP commands should be preceded by an ANSI escape sequence to make MXP tags difficult to send by other players.  The MXP control sequence is:

<ESC> [ # z

# is a control tag number defined in the MXP specification.  Certain MXP tags can only be sent when specific control situations are enabled.  See the MXP specification for more information.

Sending MXP Tags

To send an MXP tag, surround the MXP tag text with the ASCII characters ETX and EOT (characters with byte values 3 and 4, respectively).

Receiving MXP messages from clients

The MXP specification also requires that the client be able to send secure messages to the MUD server (most notably for the <VERSION> and <SUPPORT> identification commands).  When a MXP message is received from a node, wait_for_input() will return with that node number, and game.mxpmsg$ will contain the full text of the MXP message received with the MXP control sequence stripped from the beginning of the message.

Example

This block of code will return the text required to create a clickable MXP command.  If a user clicks on the link that is generated when the resulting text is sent to the node, the command stored in the cmd$ variable will be sent by the node’s MXP-enabled client to the server.  The text in the variable text$ will be the only text that should be shown to the user.

#define ETX           chr$(3)
#define EOT chr$(4)
#define MXP_TAG(i, s) chr$(27) + "[" + string$(i) + "z" + ETX + (s) + EOT

function mxp_command$(ply, cmd$, text$)
{
if !node[ply].mxp then
return text$;

return MXP_TAG(4, "SEND HREF=\"" + cmd$ + "\"") + text$ + MXP_TAG(4, "/SEND");
}