Net commands

From SRB2 Wiki
Jump to navigation Jump to search

Net commands (also known internally as netxcmds or textcmds) are networked commands sent to players in a netgame to perform certain actions. Some net commands can be sent by any player in the netgame, while others can only be sent by the server or a verified admin. The majority of net commands are sent as a response to using certain console commands or modifying certain console variables, though some can be sent for other reasons (e.g. XD_ADDPLAYER, which is sent to add a player to the netgame).

In order for a player to run net commands, each new net command is added to a local buffer. After collecting all net commands for the current gametic, this buffer is sent to the server via the PT_TEXTCMD or PT_TEXTCMD2 packets. Then, after collecting net command buffers from all players in the netgame (including the server themselves) for each tic (or multiple tics), the server sends them back to everyone (including themselves again) via PT_SERVERTICS packets. Lastly, the players then run the net commands from all the collected buffers locally, so the game is synchronised for everyone. If an illegal net command is sent – e.g., a map change command sent by someone who isn't the server or admin, or the net command has an invalid ID number – the game automatically detects this and kicks the player out of the netgame.

List of net commands

Decimal ID Hex ID Name Purpose
0 0x00 none Unused
1 0x01 XD_NAMEANDCOLOR Updates a player's current name, color and skin. This is sent whenever a player modifies name, skin, or color. This is also sent by players joining the server.
2 0x02 XD_WEAPONPREF Updates other player preferences. This is sent whenever a player modifies flipcam or analog. This is also sent by players joining the server.
3 0x03 XD_KICK Kicks or bans a player from the server. This is sent when the server or admin uses the kick or ban commands. This will also be sent when player has sent an illegal net command.
4 0x04 XD_NETVAR Synchronises a networked console variable for everyone. This is sent when the server or admin modifies a console variable with the CV_NETVAR flag.
5 0x05 XD_SAY Runs a say command. This is sent when a player is sending messages through chat mode, or uses the commands say, sayto, sayteam, or csay.
6 0x06 XD_MAP Runs a map change command. This is sent when the current map being played has finished and the game is ready to change to the next map. This is also sent when the server or admin uses the map command, or changes the map from the menu.
7 0x07 XD_EXITLEVEL Finishes the current level, starting the corresponding tally screen for the gametype. This is sent when all players have finished the current level, or when the server or admin uses the exitlevel command.
8 0x08 XD_ADDFILE Adds a file to the game. This is sent when the server uses the addfile command. If an admin uses the addfile command, they will send a XD_REQADDFILE command instead to request the server to add the file.
9 0x09 XD_PAUSE Pauses/unpauses the game. This is sent when the pause command or the Pause control is used. Normally, the game can only be paused/unpaused by the server or admin; however, if pausepermission is enabled, anyone is allowed to pause/unpause the game.
10 0x0A XD_ADDPLAYER Adds a player to the netgame. This is sent by the server to add any players waiting to join the game, after they have downloaded all required files and $$$.sav.
11 0x0B XD_TEAMCHANGE Sends a team change command. This is sent when the teamchange or serverteamchange commands are used, or a player changes their team from the menu.
12 0x0C XD_CLEARSCORES Clears all player scores. This is sent when the server or admin uses the clearscores command.
13 0x0D none Unused – This was formerly the ID for XD_LOGIN, which was used to run login requests. From v2.1.25 onwards, login attempts are now handled by the PT_LOGIN packet type.
14 0x0E XD_VERIFIED Awards admin privileges to a player. This is sent when the server uses the promote command.
15 0x0F XD_RANDOMSEED Unused – This was formerly sent by the server to set a new random seed when the map is changed, but since v2.1 this is handled by XD_MAP, making this net command type deprecated.
16 0x10 XD_RUNSOC Runs a SOC file. This is sent when the server or admin uses the runsoc command.
17 0x11 XD_REQADDFILE Sent by an admin to request the server to add a file to the game.
18 0x12 XD_DELFILE Sent by the server or admin to delete a file from the game. This is unused, as all code relating to deleting files is disabled in SRB2.
19 0x13 XD_SETMOTD Sets the Message of the day. This is sent when the server or admin uses the motd command.
20 0x14 XD_SUICIDE Kills a player. This is sent when a player uses the suicide command.
21 0x15 XD_DEMOTED Removes admin privileges from a player. This is sent when the server uses the demote command.
22 0x16 XD_LUACMD This is sent when the server or admin uses a networked Lua-defined console command.
23 0x17 XD_LUAVAR Unimplemented – This is intended to be sent by the server or admin when a Lua-defined console variable is changed, and a function for it is to be called.
  Network documentation [view]
Packet types PT_ASKINFOPT_SERVERINFOPT_PLAYERINFO
Other Net commands