ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new:multiplayer

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
new:multiplayer [2018/02/19 12:22]
korshun
— (current)
Line 1: Line 1:
-====== 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:​ 
-<​code>​ 
-if (IsServer()) 
-{ 
-    // Run serverside gameplay code. 
-} 
-if (IsClient()) 
-{ 
-    // Draw hud, spawn effects. 
-} 
-</​code>​ 
- 
-Use ''​IsClient''​ or ''​IsServer''​ to verify that clientside code is not run serverside, while not breaking singleplayer:​ 
-<​code>​ 
-if (!IsClient()) 
-    error("​This function must not be called serverside"​);​ // does not warn in singleplayer 
-</​code>​ 
  
new/multiplayer.1519035728.txt.gz ยท Last modified: 2018/02/19 12:22 by korshun