Jump to content

C# API


DxWo

Recommended Posts

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.

Link to comment
Share on other sites

in API.cs change public class API : ModApiAbstract to

public class API : IModApi

 

then use within API class:

 

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

Link to comment
Share on other sites

in API.cs change public class API : ModApiAbstract to

public class API : IModApi

 

then use within API class:

 

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.

Link to comment
Share on other sites

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:

 

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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...