Difference between revisions of "Modding:Modder Guide/APIs/Multiplayer"

From Stardew Valley Wiki
Jump to navigation Jump to search
(expand)
(+ footer nav links)
Line 20: Line 20:
 
}
 
}
 
</source>
 
</source>
 +
 +
{{modding guide footer
 +
|prev = [[Modding:Modder Guide/APIs|SMAPI reference]]
 +
|next =
 +
}}

Revision as of 18:29, 7 June 2018

Creating SMAPI mods SMAPI mascot.png


Modding:Index

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.

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:

int animalID = this.Helper.Multiplayer.GetNewID();
var animal = new FarmAnimal("Cow", animalID, ownerID);

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:

foreach (GameLocation location in this.Helper.Multiplayer.GetActiveLocations())
{
   // do stuff
}