This is an old revision of the document!
You can check if a script is running serverside, clientside or in singleplayer using functions provided by ACSUtils.
In singleplayer, the same engine instance is both a server and a client. Both IsServer()
and IsClient()
return true in singleplayer.
In ZDoom and GZDoom multiplayer (but not Zandronum's), all players are both servers and clients, just like in singleplayer.
In regular Zandronum multiplayer, the server is only a server and clients are only clients, obviously.
Yet, if Zandronum were to allow hosting non-dedicated servers, where a player allows others to connect to their singleplayer game without launching a separate engine instance, the hosting player would be both a server and a client, while other players in the game would be only clients.
bool IsServer()
– returns true if the script is running on a server.bool IsClient()
– returns true if the script is running on a client.bool IsServerOnly()
– returns true if the script is running on a server that is not also client.bool IsClientOnly()
– returns true if the script is running on a client that is not also server.The definitions above enable writing ACS code that functions correctly in both singleplayer and multiplayer without singleplayer being a special case. Just make sure
All detection of clients and servers is founded on two functions: ConsolePlayerNumber and IsNetworkGame.
IsClient()
simply checks if ConsolePlayerNumber is not -1.