• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

C# API

DxWo

Refugee
Good day everyone, i recently came across an old C# API script for 7days but cant seem to get it to work. the API class extends ModApiAbstract but that is not found in the Assembly-CSharp.dll that i have referenced in the solution. What am i missing here?

Here is the exact error: "The type or namespace 'ModApiAbstract' could not be found (are you missing a using directive or an assembly reference?).

Again, i do have Assembly-CSHarp listed under the references for my project, but im obviously missing something.

 
in API.cs change public class API : ModApiAbstract to

public class API : IModApi

then use within API class:

Code:
public void InitMod()
       {
           ModEvents.GameStartDone.RegisterHandler(GameAwake);
           ModEvents.GameShutdown.RegisterHandler(GameShutdown);
           ModEvents.SavePlayerData.RegisterHandler(SavePlayerData);
           etc
           etc
       }
for registering eventhandlers for the api hooks.

Cheers

 
in API.cs change public class API : ModApiAbstract topublic class API : IModApi

then use within API class:

Code:
public void InitMod()
       {
           ModEvents.GameStartDone.RegisterHandler(GameAwake);
           ModEvents.GameShutdown.RegisterHandler(GameShutdown);
           ModEvents.SavePlayerData.RegisterHandler(SavePlayerData);
           etc
           etc
       }
for registering eventhandlers for the api hooks.

Cheers
Should i then remove all the other Public overrides that were in the api.cs class? They are all erroring out a non suitable method.

 
Should i then remove all the other Public overrides that were in the api.cs class? They are all erroring out a non suitable method.
They are not overrides anymore:

Code:
public class API : IModApi
   {

       public void InitMod()
       {
           ModEvents.GameStartDone.RegisterHandler(GameStartDone);
           ModEvents.GameShutdown.RegisterHandler(GameShutdown);
           ModEvents.SavePlayerData.RegisterHandler(SavePlayerData);
           ModEvents.PlayerSpawnedInWorld.RegisterHandler(PlayerSpawnedInWorld);
           ModEvents.PlayerDisconnected.RegisterHandler(PlayerDisconnected);
           ModEvents.ChatMessage.RegisterHandler(ChatMessage);
       }

       public void GameStartDone()
       {

       }

       public void GameShutdown()
       {

       }

       public void PlayerDisconnected(ClientInfo _cInfo, bool _bShutdown)
       {

       }

       public void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)
       {

       }

       public void SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile)
       {

       }

       public bool PlayerLogin(ClientInfo _cInfo, string _compatibilityVersion, StringBuilder sb)
       {

       }

       public bool ChatMessage(ClientInfo _cInfo, EChatType _type, int _senderId, string _msg, string _mainName, bool _localizeMain, List<int> _recipientEntityIds)
       {

       }
   }
Cheers

-edit- those are not all available ModEvents but just to get the drift

 
Last edited by a moderator:
Back
Top