13 years
edited 8 years
Description
The purpose of this library is to offer a single function which checks if the game is played in single player mode or multiplayer.
Important: This function must be used only to define if the player is in single player or in Bnet or lan game. This function will fail in replays (it will show that you're in a LAN game by default).
Credits to Nestharus for the awesome solution to this problem
Requirements
- None
Actual Code
Example
The purpose of this library is to offer a single function which checks if the game is played in single player mode or multiplayer.
Important: This function must be used only to define if the player is in single player or in Bnet or lan game. This function will fail in replays (it will show that you're in a LAN game by default).
Credits to Nestharus for the awesome solution to this problem

Requirements
- None
Actual Code
1 /******************************************************************2 * SINGLE PLAYER DETECTOR V3.0 *3 * By moyack *4 * 2012 *5 * =================================== *6 * Exclusive resource from wc3jass.com *7 * =================================== *8 ******************************************************************/9 library SinglePlayerDetector10 /*The purpose of this library is to offer a single function which checks if11 the game is played in single player mode or multiplayer. It offers only12 one function:13 14 isSinglePlayer: takes nothing and returns a boolean.15 16 If true, the game is being run in single player mode, else, in multiplayer17 CREDITS TO NESTHARUS for the improved and nice solution to this problem.18 It passed from a long code to a simple line function.19 Credits to Magtheridon96 for the library optimization20 */21 22 globals23 private boolean sp = ReloadGameCachesFromDisk()
24 endglobals25
26 function IsSinglePlayer takes nothing returns boolean
27 return sp28 endfunction29 30 endlibrary
Example
1 scope test initializer init
2 3 private function init takes nothing returns nothing
4 if IsSinglePlayer() then
5 call DisplayTimedTextFromPlayer(Player(0), 0,0,10, "You're playing alone, forever, happy. You can cheat")
6 else7 call DisplayTimedTextFromPlayer(Player(0), 0,0,10, "You're playing multiplayer. You can't cheat")
8 endif9 endfunction10 11 endscope