The multiplayer API provides methods to support modding in a multiplayer context. This API is still minimal, but much more will be added in later versions of SMAPI.
−
The multiplayer API provides methods to support modding in a multiplayer context:
+
+
__TOC__
+
==Methods==
+
===GetNewID===
+
In some cases the game expects a 'multiplayer ID' value, which is a unique 64-bit number. This is mainly intended for cases where the game expects a multiplayer ID for data sync, such as when creating farm animals:
<source lang="c#">
<source lang="c#">
−
// get a unique multiplayer ID (e.g. for animal IDs)
+
int animalID = this.Helper.Multiplayer.GetNewID();
−
int uniqueID = this.Helper.Multiplayer.GetNewID();
+
var animal = new FarmAnimal("Cow", animalID, ownerID);
+
</source>
−
// get the locations being sync'd from the main player
+
===GetActiveLocations===
+
In multiplayer mode, the game doesn't sync all locations to other players. Each farmhand will receive data for their current location, the farm, farmhouse, and farm buildings. You can get a list of the locations being sync'd:
+
<source lang="C#">
foreach (GameLocation location in this.Helper.Multiplayer.GetActiveLocations())
foreach (GameLocation location in this.Helper.Multiplayer.GetActiveLocations())