ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new:multiplayer

This is an old revision of the document!


Multiplayer support

These functions enable proper multiplayer support in mods.

Terminology

  • A port instance is a server if it runs gameplay code.
  • A port instance is a client if it runs non-gameplay code that only affect the visuals.
  • A port instance can be both a client and a server (e.g. in singleplayer)

Examples

  • Zandronum client – client
  • Zandronum server – server
  • Singleplayer – both client and server
  • ZDoom multiplayer nodes – both client and server

Note that ZDoom multiplayer is serverless, and all players run both clientside and serverside code.

Functions

  • bool IsClient() – returns true if the script is running on a client (which may also be a server).
  • bool IsServer() – returns true if the script is running on a server (which may also be a client).
  • bool IsClientOnly() – returns true if the script is running on a client that is not also a server.
  • bool IsServerOnly() – returns true if the script is running on a server that is not also a client.

Using IsClient and IsServer correctly ensures that your mod runs correctly in both singleplayer and multiplayer:

if (IsServer())
{
    // Run serverside gameplay code.
}
if (IsClient())
{
    // Draw hud, spawn effects.
}

Use IsClient or IsServer to verify that clientside code is not run serverside, while not breaking singleplayer:

if (!IsClient())
    error("This function must not be called serverside"); // does not warn in singleplayer
new/multiplayer.1519035719.txt.gz · Last modified: 2018/02/19 12:21 by korshun