- Main Menu
This is an old revision of the document!
Setting up your game for online multiplayer is considered an advanced topic, so it is recommended that you familiarize yourself with 001 Game Creator in general before attempting to implement this.
An online game generally consists of multiple instances of a game running at the same time, where one instance of the game is considered the server whom hosts the game, and the rest of the instances of the game are considered the clients whom connect to the server.
The mechanism used for network communication is TCP/IP using BSD sockets.
The following is an overview of the procedure of how online multiplayer games function in 001 Game Creator:
During the development of your game, 001 Game Creator offers an option for you to execute multiple instances of the same game by using the “Launch instances for network games” option within the testing options. When the value is 2 or higher, the first instance will be considered the server and the second instance will be considered the client. That is, “Is Server” use value will return true for the first instance and false for every other instance. However, if you simply execute the same game multiple times on the same computer once the game is built, each instance will be considered a client unless the game is built as a dedicated server.
Regardless of whether the game is launched as a client or server, any instance may either host a game (become the server) or connect to one (become a client). This allows you to setup a game where any user of your game can either be the server or a client, simply by allowing the user to make that choice.
Generally, the server makes final calls about whether a client moves to a particular location, damages another player, and so forth. A client generally receives information about the game/map from the server, and sends general commands or intermittent states to the server to delegate to everyone.
When the server receives a connection from a client, it would probably be wise to have the two communicate a bit before throwing everyone into the game. For example, the server can take this opportunity to validate the IP address of the incoming connection, or wait for a secret password from the client to enter a particular game. It all comes down to how the game designer intends to validate a player and what information the server and client need to know about each other.
Most gameplay elements should be transmitted as they happen or change. However, movement is particularly susceptible to noticeable performance issues because of common network issues, such as low latency situations or bandwidth limitations.
A simple solution for handling movement, is to intermittently have the client inform the server of its current location. The server can simply relay this back to the other clients and those clients can merely use a “Walk to Location” event to that new location. It will look just as good as what the other client probably performance, but reduces the amount of data transmitted over the network.
Because 001 Game Creator allows you to design how networking actually functions, there is no particular way for it to prevent cheating or hacking. It is the responsibility of the game designer to script things in a way that is most fitting.
In terms of security, it is best to not transmit plain text passwords - consider using hash or encryption algorithms. And in terms of cheating, it is best to validate the network messages that are received from other clients to ensure that the information is reasonable. For example, if a player reports being in one position, but then quickly in another, unrealistic position across the entire map based on a distance calculation, it would be best to trigger some action that would kick the player or report it to a moderator.