Modding:SaveGame Data Storage: Difference between revisions

From Vintage Story Wiki
(typo)
Line 32: Line 32:
     {
     {
         ICoreServerAPI serverApi;
         ICoreServerAPI serverApi;
        List<string> lfgList;
         public override void StartServerSide(ICoreServerAPI api)
         public override void StartServerSide(ICoreServerAPI api)
         {
         {
             serverApi = api;
             serverApi = api;
            api.Event.GameWorldSave += OnSaveGameSaving;
            api.Event.SaveGameLoaded += OnSaveGameLoading;


             api.RegisterCommand("lfg", "List or join the lfg list", "[list|join|leave]", OnLfg);
             api.RegisterCommand("lfg", "List or join the lfg list", "[list|join|leave]", OnLfg);
Line 44: Line 49:
In this class, we create an override for the <code>StartServerSide</code> method. This method of the <code>ModSystem</code> is called for all mods on the Server side by the game.
In this class, we create an override for the <code>StartServerSide</code> method. This method of the <code>ModSystem</code> is called for all mods on the Server side by the game.


When the Server side starts, we register a command that players will use to access our list of those looking for group. This will be <code>/lfg</code> with the arguments list, join or leave.
When the Server side starts, we add two event delegates that will retrieve our list from the <code>SaveGame</code> when the we game loads, and that will save the list when the game saves. We also register a command that players will use to access our list of those looking for group. This will be <code>/lfg</code> with the arguments list, join or leave.


Let's create the delegate <code>OnLfg</code> that will be called when a player enters this command.
Let's create these event delegates!


== Storing and Retrieving the List ==
== Storing and Retrieving the List ==