Make sure you understand how to use Drag & Drop and a bit of GML before you start. Make sure you know what variables & INI files are. This post will mostly focus on setting your game up. It'll describe what you need to do to get the game connected to the server, how to make the connection, and lastly how to show a login screen and have players log in to your game.
When starting a new project, there are a few things you need to do before your game will be able to connect to GameMaker Server. Firstly, you'll need to register your game on the GameMaker Server-website.
The GameID can be found by opening "Global Game Settings" and then clicking on the tab "Loading". The GameID is the number in the text box labelled "Game Identifier" at the bottom of the window.
The GameID can be found by opening "Global Game Settings". The GameID is the number in the text box labelled "Game Identifier" at the left upper part of the window.
Open up the GameMaker Server website and login if you haven't already. If you're not registered as a developer, click your name in the upper right corner of the page, and then click "Register as a developer" and follow the steps on the web page.
Now that you're registered as a developer, click the "Developer" tab on the menu bar at the top of the page. Scroll down to the "Register a new game"-section. Enter the GameID of your game, and type in a title. The title can be changed later if you want. The GameID however, cannot be changed. If you want to use a new GameID, you'll need to create a new game.
After you've registered your game, the game will be able to connect to the server. To do so, you should set up an object that initializes the extension. Make sure you've added the extension to your game.
To add an extension, double-click "Extension Packages", select "GameMaker Server+" on the right, and press the Arrow left-button to move it to the left. If you don't see "GameMaker Server+" in the list, click "+Install", "+Install" again and load the "GameMaker Server X.X.XrX - GameMaker 8 and 8.1.gex" file (the file can be found in the download).
To add an extension, right-click "Extensions", select "Import Extension", and load the "GameMaker Server X.X.XrX - Studio (All/Windows).gex" file (the file can be found in the download). Make sure the file type, in the list box in the bottom right corner of the window is set to "GameMaker Legacy Extension". You should load the Windows file if you do not plan on releasing your game on other platforms. If you do plan on releasing on other platforms, select the All version. This version will also work when exporting to Windows. This can easily be changed later on.
Games made in GM:Studio will need an extra object. Create an object, and name it "GMS". Add the following code (Control -> Execute a piece of code):
Create:
Step:
Draw:
Lastly, if you're using the All version of GameMaker Server, add this code in the networking event:
Make sure the object is marked as Persistent, and the depth is set to a low value like -100000.
If you see an error stating global.__set is not recognised/set, that means you're calling another GameMaker Server-function before calling gms_init(...). gms_init(...) should be called before any other GameMaker Server function.
Add the following piece of code to either the GMS object, or another initialization object (this object will be referenced later on as "GMS". Make sure the object is persistent). gms_settings(...) must be called before any other GameMaker Server function, but after gms_init:
The Drag & Drop action "Server settings" on the tab "Online 1" and the Drag & Drop action "Next Room" on the tab "Main 1" can also be used. When using the Drag & Drop action, the simple mode is always enabled.
Add the following code to the Game End event of the GMS object:
The Drag & Drop action "Logout" on the tab "Online 1" can also be used.
It is important that you log out correctly. When a player logs out incorrectly, it is possible that not all data is saved properly on the server side.
obj_player and obj_other_player should be two different objects. The "player object" (obj_player) should be the object in which you place all game logic. Walking, shooting, health, setting variables, etcetera.
The "other player object" (obj_other_player) will be representing all other players that are online. Every player that is online will get an instance of the "other player object". You should not put any game logic in this object. This object should not be put in a room. This will be done automatically by the extension.
Add a sprite and some logic to make the object move when pressing the arrow or WASD keys to the obj_player object.
Create a new object, and name it something like obj_login. Add this piece of code to the create event:
The Drag & Drop action "Show a login window" on the tab "Online 1" can also be used.
When the user logs in the Event User 15 event is called. If the login window is closed, event user 14 is called.
Add the following code to the Event User 15 event:
The Drag & Drop action "Next Room" on the tab "Main 1" can also be used.
Create 3 rooms: rm_init, rm_login and rm_play. Add the GMS object to rm_init, the obj_login object to rm_login, and the obj_player object to rm_play. You should now be able to run the game and walk around. When running a second instance of the game, and logging in to a different user name, you should be able to see the other player.
Note: As JeTSpice pointed out, you cannot set the player object to be the parent of the other player object, or vice versa. Instead, you should create a common parent object, such that both the player and other player object have the common parent object as their parent.