This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
functions:isclient [2017/03/17 17:25] – [Examples] korshun | functions:isclient [2017/06/19 21:17] – korshun | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== IsClient ====== | ====== IsClient ====== | ||
- | {{tag>zdoom zandronum info needs_examples}} | + | {{tag> |
'' | '' | ||
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 | + | 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, | ||
- | <note important> | + | <note important> |
+ | |||
+ | <note warning>'' | ||
===== Examples ===== | ===== Examples ===== | ||
- | Using IsClient and [[IsServer]] ensures that your mod runs correctly in both singleplayer and multiplayer: | + | Using IsClient and [[IsServer]] |
< | < | ||
if (IsServer()) | if (IsServer()) | ||
{ | { | ||
- | // Run serverside code. | + | // Run serverside |
} | } | ||
if (IsClient()) | if (IsClient()) | ||
{ | { | ||
- | // Run clientside code. | + | // Draw hud, spawn effects. |
} | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | Use it to verify that clientside code is not run serverside, while not breaking singleplayer: | ||
+ | < | ||
+ | if (!IsClient()) | ||
+ | error(" | ||
</ | </ |