ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


functions:isclient

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
functions:isclient [2017/03/17 17:25] – [Examples] korshunfunctions:isclient [2017/06/19 21:17] korshun
Line 1: Line 1:
 ====== IsClient ====== ====== IsClient ======
-{{tag>zdoom zandronum info needs_examples}}+{{tag>zandronum info needs_examples}}
 ''bool IsClient()'' ''bool IsClient()''
  
Line 6: Line 6:
 Returns true if the script is running on a client. Returns true if the script is running on a client.
  
-Any running instance of ZDoom that has display and input capabilities is considered as a client. +Any running instance of ZDoom that has display and input capabilities is considered a client. 
  
 If the instance is a client, graphics effects (clientside actors and hud) should be enabled for it. If the instance is a client, graphics effects (clientside actors and hud) should be enabled for it.
Line 15: Line 15:
   * A singleplayer game.   * A singleplayer game.
   * A client in client-server Zandronum multiplayer (but not the server).   * A client in client-server Zandronum multiplayer (but not the server).
-  * A client that is also acting as a server for other clients (this mode is not supported in Zandronum yet).+  * A client that is also acting as a server for other clients (this mode is not supported in Zandronum yet but other game engines have it)
 +  * A player in (G)ZDoom multiplayer, which is not client-server, but makes all players run exactly the same game.
  
-<note important>**All** players are both servers and clients in **ZDoom multiplayer**, which is not client-server.</note>+<note important>**All** players are both servers and clients in **(G)ZDoom multiplayer**, which is not client-server.</note> 
 + 
 +<note warning>''!IsClient()'' is **not** equivalent to ''IsServer()''. Both can be true.</note>
  
 ===== Examples ===== ===== Examples =====
-Using IsClient and [[IsServer]] ensures that your mod runs correctly in both singleplayer and multiplayer:+Using IsClient and [[IsServer]] correctly ensures that your mod runs correctly in both singleplayer and multiplayer:
 <code> <code>
 if (IsServer()) if (IsServer())
 { {
-    // Run serverside code.+    // Run serverside gameplay code.
 } }
 if (IsClient()) if (IsClient())
 { {
-    // Run clientside code.+    // Draw hud, spawn effects.
 } }
 +</code>
 +
 +
 +Use it 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> </code>