This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
client_server_detection [2019/09/05 20:45] – [How it works] korshun | client_server_detection [2019/09/05 20:54] (current) – [Writing robust multiplayer code] korshun | ||
---|---|---|---|
Line 43: | Line 43: | ||
{ | { | ||
// Draw hud, spawn effects. | // Draw hud, spawn effects. | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | You can also make sure that a serverside-only function is not called on the client, and a clientside-only function is not called on the server. | ||
+ | |||
+ | < | ||
+ | function ServersideOnlyFunction(void) | ||
+ | { | ||
+ | // writing if (IsClient()) would incorrectly display the warning in singleplayer. | ||
+ | if (!IsServer()) | ||
+ | printbold(s:" | ||
+ | | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | function ClientsideOnlyFunction(void) | ||
+ | { | ||
+ | // writing if (IsServer()) would incorrectly display the warning in singleplayer. | ||
+ | if (!IsClient()) | ||
+ | printbold(s:" | ||
+ | | ||
+ | ... | ||
} | } | ||
</ | </ | ||
Line 52: | Line 74: | ||
'' | '' | ||
- | '' | + | '' |
- | + | ||
- | It checks if the multiplayer is real using [[zan> | + | |
- | If the engine is not Zandronum, the function returns true, because in ZDoom/ | + | If the engine is not Zandronum, the function returns true, because in ZDoom/ |
If the engine is Zandronum, the function returns false if it's real multiplayer, | If the engine is Zandronum, the function returns false if it's real multiplayer, |